Jump to content

Using PHP / PW in an Interactive Shell on Windows


horst
 Share

Recommended Posts

Hi,

regarding to a BlogPost from @Ryan yesterday, I want share a simple solution for all windows user, but the comments cannot show

<?php 

start tags. So I post my comment here and link to each other.

-------------------------------------------------------------------------------------------------------------------------------------

You can mimic this, for example on windows, very easy like this:

1) create a php file, here named "pwphp.php", with this content:

<?php
echo "PHP (" . phpversion() . ") - Interactive mode enabled\n";
$fp = fopen('php://stdin', 'r');
define('quit', 'quit');
$in = '';
while('quit' != substr($in, 0, 4)) {
    echo 'php > ';
    $in = trim(fgets($fp));
    eval($in);
    echo "\n";
}
exit(0);

.
2) create a windows batch file like this, (here named as pwphp.bat):

@ECHO OFF
SET phpexe=C:\php-54\php.exe
SET phpparams=-d output_buffering=0

TITLE PHP Interactive Mode :: %CD%
"%phpexe%" %phpparams% %~dp0pwphp.php
TITLE %CD%

Drop both files into the same directory. But this directory must be in your systempath!

Now open a windows shell and type: pwphp and have fun!  :)

To finish and leave Interactive Mode, you type "quit".

  • Like 10
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...