JJD JJD - 3 months ago 42
PHP Question

php-cli require_once() failing on ubuntu works on mac

I am working with the voip.ms php api I wish to run a php script from the cli it works fine on my mac in terminal but on the ubuntu server it fails...

the script:

$voipms = new VoIPms();

the begining of class.voipms.php

class VoIPms{

the error

first it spits out 2000+ lines from class.voipms.php then

PHP Fatal error: Class 'VoIPms' not found in /root/voipreg/check.php on line 3

obviously the class is in class.voipms.php and the script can find class.voipms.php because it gets printed to the cli and everything runs fine from terminal on my mac so I am rather confused!

Any help would be amazing!


PHP short tags (just <? vs the full tag <?php) are likely disabled on the Ubuntu system. I would suggest not using short tags as they are not enabled everywhere like the full tag is. If not enabled, you will get exactly what you are describing. PHP doesn't recognize the file as code and just spits it out as text.

While you can enable the short tags in php.ini, I would suggest just not using it. You can't rely on it being enable everywhere and it's not like it is that hard to just type out the full thing. You can also still use the short echo tag <?=, even with short tags disabled, for a while now.