我有这个代码,它完美无缺:
if(in_array($_SERVER['HTTP_HOST'], array('localhost', '127.0.0.1'))) // localhost
{
$root = '';
}
else
{
if(!empty($_SERVER['HTTPS'])) // https
{
$root = 'https'.'://'.$_SERVER['HTTPS_HOST'];
}
else // http
{
$root = 'http'.'://'.$_SERVER['HTTP_HOST'];
}
}
我这样回答:
<img src="<?php echo $root.htmlspecialchars($path, ENT_QUOTES); ?>" />
我想将代码包装在函数中:
function root() {
// that code
}
然后以类似的方式回应它:
<img src="<?php echo root().htmlspecialchars($path, ENT_QUOTES); ?>" />
怎么做?因为我的例子不起作用:(
答案 0 :(得分:3)
你的功能没有返回任何值,所以没有什么可以回应......
尝试在功能结束时添加int line_cnt = 0;
int longestLine = longestline("c:\\inputfile.txt", &line_cnt)//determine longest line of file.
//char line[83];
char *line = calloc(longestLine + 1, 1);//create buffer to accommodate longest of lines found in file
//AIRLINE plane[12] = {0};
AIRLINE *plane = calloc(line_cnt, sizeof(AIRLINE));
:
return $root