Call to undefined function phpversion()

Richard G

Verified User
Joined
Jul 6, 2008
Messages
12,558
Location
Maastricht
Some application generates errors like this:
Code:
Uncaught Error: Call to undefined function phpversion()
Same for time. So I need both the functions phpversion and time to be compile with php.

I found this:

However, I always get confused with modules and functions and what I have to use to get it working.

Do I need for example --with-phpversion or --enable-phpversion or something completely different to get this to work in php?
Same for time and file_exists()?
 
Last edited:
Upping this. Anybody a clue?
My first thought this would have to be compiled in somehow.

But after that I tried using the phpversion command with echo and then it shows the phpversion. Same with time.
So I thought it was application related. They say it's server related.

Now this is the whole line:
Code:
PHP Fatal error:  Uncaught Error: Call to undefined function phpversion() in /home/user/domains/somedomain.com/public_html/index.php:3\nStack trace:\n#0 {main}\n  thrown in /home/user/domains/somedomain.com/public_html/index.php on line 3

This is line 3:
Code:
$phpVersion = phpversion();

These are the first few lines:
Code:
<?php

$phpVersion = phpversion();
if (version_compare($phpVersion, '7.0.0', '<'))
{
        die("PHP 7.0.0 or newer is required. $phpVersion does not meet this requirement. Please ask your host to upgrade PHP.");
}

$dir = __DIR__;
require($dir . '/src/XF.php');

It's not throwing this continuously but a very lot and I would like to know where it's coming from since when i use echo phpversion(); in a php file, it shows me the php version which makes me think the issue is not server related.
 
I can't help but workarround could be made simple maybe.

Check yourself and that customer / developer which php versions and settings needed.
Then delete the php version check part in apllication , then test.

Sometimes checks are also related to connectors / plugins that use that call from that line
 
Last edited:
No that won't help, because in another part of an addon, I also have the same issue with a time request.
Deleting statements will probably remove those errors, but I want to know if this could be server related or if this must be application related.
 
No that won't help, because in another part of an addon, I also have the same issue with a time request.
Deleting statements will probably remove those errors, but I want to know if this could be server related or if this must be application related.
phpinfo(); shows php version? or gives error too?
 
Same thing with this time thing:
Code:
PHP Fatal error:  Uncaught Error: Call to undefined function file_exists() in /home/user/domains/somedomain.com/public_html/ips2xf.php:4\nStack trace:\n#0 {main}\n  thrown in /home/user/domains/somedomain.com/public_html/ips2xf.php on line 4

And this is the beginning of that ips2xf.php script:
Code:
<?php

$fileDir = dirname(__FILE__);
if (file_exists($fileDir . '/301config.php'))
{
        include($fileDir . '/301config.php');
}
This is present in the public_html folder and so is the 301config.php file.

Odd thing is that in both cases the errors seem to be caused by bots. So for example this happend on 16:10:40 (GMT+1) and when I look in the acces log, before it was MJ12bot and error 500 and now bingbot. Have a look at this:

Code:
"GET /forums/dreambox-algemeen.126/page-3 HTTP/1.1" 500 4019 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0
like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Odd isn't it? This is one of the index.php line 3 issues.

I don't know why this is causing an error 500. When I put this after domain name, then I get the correct page.
So why the error 500 and why on exact this time and second that odd index.php line 3 error is thrown?
 
Back
Top