Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

executing php script in console

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

like image 783
David Menard Avatar asked Jun 30 '10 18:06

David Menard


2 Answers

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?

like image 168
Gordon Avatar answered Sep 28 '22 20:09

Gordon


Try:

<?php

instead of

<?

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

like image 33
psmears Avatar answered Sep 28 '22 20:09

psmears