Heim  >  Artikel  >  Backend-Entwicklung  >  PHP引用有关问题

PHP引用有关问题

WBOY
WBOYOriginal
2016-06-13 13:23:34802Durchsuche

PHP引用问题
我在A文件中引用B文件的函数cut(),在A页面中写include_once("B.php");然后在下面调用但不知道为什么老是运行报错Fatal error: Call to undefined function cut() in D:\XAMPP1.7.3\xampp\htdocs\web\index.php on line 233
这个是不是说没有定义CUT函数?但我明明定义了啊。然后查看A页面源文件的时候,本该显示结果的那段显示的却是我的CUT函数代码。
CUT函数是
function cut($Str, $Length) {//$Str为截取字符串,$Length为需要截取的长度 

global $s;
$i = 0;
$l = 0;
$ll = strlen($Str);
$s = $Str;
$f = true; 

while ($i if (ord($Str{$i}) $l++; $i++;
} else if (ord($Str{$i}) $l++; $i += 2;
} else if (ord($Str{$i}) $l += 2; $i += 3;
} else if (ord($Str{$i}) $l += 1; $i += 4;
} else if (ord($Str{$i}) $l += 1; $i += 5;
} else if (ord($Str{$i}) $l += 1; $i += 6;


if (($l >= $Length - 1) && $f) {
$s = substr($Str, 0, $i);
$f = false;


if (($l > $Length) && ($i $s = $s . '...'; break; //如果进行了截取,字符串末尾加省略符号“...”
}
}
return $s;
}
?>

不知道我表达的清楚不,希望有人能帮忙解答。

------解决方案--------------------
你开启了php断标签了吗,你A文件的php标签应该是------解决方案--------------------

探讨

你开启了php断标签了吗,你A文件的php标签应该是
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn