0

I've been trying to run my PHP scripts on my Ubuntu 13.10 machine, but unusually it returns the PHP file contents.

php -q discover/server.php
<?

// configuration settings
require "config.php";

function pollCallback()
{
        $poller = new Poller_Discover ();
        $poller->check ();
}

$daemon = new Core_Daemon ( 'pollCallback', true );

I find this very unusual because I have already turned PHP's enable_short_tag configuration on.

ChrisM
  • 505
  • 6
  • 18

2 Answers2

0

You should try enabling short tags in the appropriate php.ini file which is being used by the CLI php command. Its location might be distribution-dependent.

alkar
  • 5,459
  • 7
  • 27
  • 43
0

If you want to run a console script like that you have 2 options, you mixed them thus it doesnt work:

Use of a SHEBANG:

#!/usr/bin/php
<?php
/*
code
*/

ran by ./discover/server.php (make sure it's executable with chmod 700 / 770 / 777).


Or sending the script to php:

<?php
/*
code
*/

ran by php -q discover/server.php.

You should also not use short tags <? /* */ ?> as they are off by default on most servers.

Also check you have the correct php.ini file, there are different versions for apache, fpm, cli (<- is what you need), cgi, ...

Daniel W.
  • 31,164
  • 13
  • 93
  • 151