5

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

David Menard
  • 2,261
  • 3
  • 43
  • 67
  • Make sure the /folder.to/php.exe in your path so php.exe can be called from any folder on your system – Sohail Jun 30 '10 at 18:07

4 Answers4

6

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?

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559
4

Try:

<?php

instead of

<?

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

psmears
  • 26,070
  • 4
  • 40
  • 48
1

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

mmattax
  • 27,172
  • 41
  • 116
  • 149
  • it can't work, unless s/he adds the `#!` line with the proper interpreters for the file, and set the eXecutable "bit" – ShinTakezou Jun 30 '10 at 18:08
1

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
  • 9,432
  • 1
  • 29
  • 39