php fatal error when call to a nested function such as time() header() etc

yip asked
php fatal-error
via

Today I met a problem above:

[03-Nov-2017 19:29:02 Asia/Shanghai] PHP Fatal error: Call to undefined function header() in /www/xxxx/api/login.php on line 5

[03-Nov-2017 19:27:37 Asia/Shanghai] PHP Fatal error: Call to undefined function dirname() in /www/xxxx/index.php on line 9

I cannot find the reason and solution. anyone helps me, thanks.

add my code.

<?php
header('Content-type:text/html; charset=utf8');
include_once dirname(__FILE__). '/global.inc.php';

echo 'HELLO WORLD';

this problem happens sometimes and have last for one day, in my online website. what i can do is to reload each 1 hour.

anyone knows how to solve it??? THXTHX


UPDATE: Server Info added: Nginx Server, CentOS release 6.3. PHP Version 5.4.41

What confuse me most is that this problem happened suddenly on my online website with no changes published.


Answer
via

A really wild guess, but these errors could be deceiving you.

[03-Nov-2017 19:29:02 Asia/Shanghai] PHP Fatal error: Call to undefined function header() in /www/xxxx/api/login.php on line 5

[03-Nov-2017 19:27:37 Asia/Shanghai] PHP Fatal error: Call to undefined function dirname() in /www/xxxx/index.php on line 9

What if header() and dirname() contain a leading unicode character that is invisible or was somehow stripped from your log files? They might look like built-in PHP functions, but maybe your code contains special characters either in compiled form, or at runtime. In other words, header() might not be what you think it is. Even though it looks that way in the log.

I suggest a quick review of the following:

Share This
Posted in: