Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No output from PHP interactive on Windows

I'm running php interactively from xampp (5.4.7) on my Win 7 machine and cannot get any output from the window. I searched around various solutions and nothing so far has worked. Here's a sample: C:\xampp>php -v PHP 5.4.7 (cli) (built: Sep 12 2012 23:48:31) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

C:\xampp>php -a
Interactive mode enabled

<?
echo "hi";
printf "hi";
fwrite (STDOUT, "hi");

any other ideas???

I also tried php -an and setting output_buffing Off in the php.ini, all to no avail.

Basically my aim is mostly to use this as a testbed for php expressions as well as running some local scripts.

like image 562
BaliDave Avatar asked Jun 28 '13 10:06

BaliDave


1 Answers

The first line I type after entering php -a is slightly different to yours:

<?php          //press Enter
echo 'This ';  //press Enter
echo 'works';  //press Enter
//Press Ctrl+z on this line to get a ^Z, then press Enter
This works
C:\Windows\System32>

The nuisance is that it returns to the Windows command prompt and you have to keep typing php -a and <?php before you can type more.

To save a bit of typing I created a shortcut, right-clicked it, opened its Properties dialog and entered the following command in the Target text box:

C:\Windows\System32\cmd.exe /k "php -a"

This shortcut opens a PHP prompt in interactive mode. Alternatively, this one starts in interactive mode and lists the PHP switches:

C:\Windows\System32\cmd.exe /k "php -h & php -a"

like image 102
Mr.Oz Avatar answered Sep 21 '22 13:09

Mr.Oz