簡體   English   中英

如何在此腳本中稱呼它?

[英]How do I call this in this script?

data.php是主文件,如果搜索詞不在數據庫中,則應調用getdata.php來獲取數據。 所以我怎么在這個腳本中稱呼它。

$db = mysql_connect($db_host, $db_username, $db_password) or die("Could not connect.");
mysql_select_db($databse_name,$db)or die(mysql_error());
$row = mysql_fetch_assoc($result);
if($row > 0){
    //show the result
}else{
    //call getdata.php
}

但是如何不使用header()調用getdata.php

...}else{
include( 'getdata.php' )
}

require('getdata.php'); 浮現在腦海

您可以按照卡洛斯所說的做,也可以使用

require('getdata.php');

這完全取決於您是否希望應用程序在getdata.php不存在時發出警告,或者是否希望應用程序產生致命錯誤(require會產生致命錯誤)。

最好使用require_once()來確保文件在任何時候都不會被多次包含。

希望這可以幫助。

這里

//這樣的東西

$ execute = /path/to/php/script.php ;

//如果需要輸出echo $ execute;

您也可以參考PHP執行運算符

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM