PHP entry level question
I expect the output of "inside test 开发者_如何学JAVAfinish" when loaded the index.php file instead I got nothing.
index.php:
<?php
@include_once('functions.php');
test();
echo "finish";
?>
inside the functions.php
there's a
<?php
function test()
{
echo "inside test";
}
You are suppressing errors by prefixing the include_once
statement with @
. Try removing it so you can see any possible errors that PHP is emitting.
@ suppresses errors. Was there a path or syntax problem? You wouldn't know because you're not getting an error output. Your code is fine.
Hehe, is it just me or just an copy/paste issue but aren't you missing the ?>
at the end of functions.php
:
<?php
function test()
{
echo "inside test";
}
and since @ is on and is suppressing errors as everyone else has mentioned, it may be the reason why there is no output.
The @ does not only suppress errors, but, in fact, suppresses all output from that file/function/whatever. Even if there were no syntax errors in your functions.php file, it would have not output anything anyway. It is generally bad practice to use the @ operator for anything, rather just write good code!
精彩评论