3

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.

25
  • 1
    can you please attach some code! We'll try to solve it as fast as we can! Commented Nov 3, 2017 at 12:03
  • 1
    You need to show your code Commented Nov 3, 2017 at 12:04
  • first check this link . it might help you. stackoverflow.com/questions/7186926/… Commented Nov 3, 2017 at 12:04
  • post the code as well Commented Nov 3, 2017 at 12:05
  • it happens sometimes, and will be fine after I reload the php-fpm, and it happens about 40~50min again. Commented Nov 3, 2017 at 12:08

1 Answer 1

1

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:

Sign up to request clarification or add additional context in comments.

2 Comments

for gods sake, don't use declare(encoding), juse use a sane editor that use utf8. it's very difficult to imagine an exception to this rule.
Agree. And just wanted to add that I didn't mean to imply that it should be done that way. Just to check and be sure the existing file(s) do not have this, such they it would alter the anticipated behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.