views:

55

answers:

4

Hey, i'm trying to execute a php in the console, but each time i run it:

php myscript.php

it only outputs the content of the file, it dowsn't run it. output:

<?
echo 'test';
?>

instead of:

test

What's wrong? I have php installed under c:/program files/php and the environment variable is set.

Thanks,

Dave

+4  A: 

Try

<?php

It might be short_open_tag is disabled in your php.ini

Tells PHP whether the short form (<? ?>) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>. Also, if disabled, you must use the long form of the PHP open tag (<?php ?>).


Edit: You might also want to read Are Short Open Tags Acceptable To Use?

Gordon
thanks everyone, since gordon posted first, he will get the accepted answer
David Menard
+4  A: 

Try:

<?php

instead of

<?

(if that works you may need to configure your installation of PHP to enable short tags.)

psmears
+1  A: 

Don't use short tags. Replace <? with <?php.

mmattax
it can't work, unless s/he adds the `#!` line with the proper interpreters for the file, and set the eXecutable "bit"
ShinTakezou
+1  A: 

use <?php instead of <?

edit Try also the -n flags from the cmd line, it avoids PHP read the ini file where short tag could be disabled

ShinTakezou