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
发布于 2011-02-22 19:49:50
...}else{
include( 'getdata.php' )
}发布于 2011-02-22 19:50:21
require('getdata.php');出现在脑海中
发布于 2011-02-22 19:58:53
你可以像卡洛斯说的那样做,或者你可以使用
require('getdata.php');这完全取决于您是希望应用程序在getdata.php不存在时生成警告,还是希望应用程序生成致命错误(require将生成致命错误)。
最好改用require_once(),以确保该文件在任何时候都不会被多次包含。
希望这能有所帮助。
https://stackoverflow.com/questions/5077667
复制相似问题