Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: How to do Press Any Key To Continue with php.exe

Posted on 2011-06-21 00:06:31 by jds

I am wondering if there is a better way to do this than what I have come up with. The
first example waits for the ENTER key to be pressed, but any other characters you press
show up on the screen

The second method works with any key being pressed, but uses exec().

Any other suggestions? Basically I am wanting the console window to stay open at the end
of the script so the user can read what was displayed in the window before the console
window closes down.

Thanks

> php test.php

<?php
//test. php

//Not the most elegant, but it works!
echo "\n\n";
echo "Press ENTER to continue... ";
$handle = fopen("php://stdin","r");
$getLine = "";
while ($getLine == ""):
$getLine = fgets($handle);
endwhile;

//A little better but uses exec()
echo "\n\n";
echo "Press ANY KEY to continue... ";
exec("pause");

?>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#2: Re: How to do Press Any Key To Continue with php.exe

Posted on 2011-06-21 11:14:38 by Richard Quadling

On 20 June 2011 23:26, JDS <jds@forerunnertv.com> wrote:
> I am wondering if there is a better way to do this than what I have come =
up
> with. The first example waits for the ENTER key to be pressed, but any ot=
her
> characters you press show up on the screen
>
> The second method works with any key being pressed, but uses exec().
>
> Any other suggestions? Basically I am wanting the console window to stay
> open at the end of the script so the user can read what was displayed in =
the
> window before the console window closes down.
>
> Thanks
>
>> php test.php
>
> <?php
> //test. php
>
> //Not the most elegant, but it works!
> echo "\n\n";
> echo "Press ENTER to continue... ";
> $handle =3D fopen("php://stdin","r");
> $getLine =3D "";
> while ($getLine == ""):
> à à$getLine =3D fgets($handle);
> endwhile;
>
> //A little better but uses exec()
> echo "\n\n";
> echo "Press ANY KEY to continue... ";
> exec("pause");
>
> ?>

@ECHO OFF
C:\PHP5\php.exe C:\Path\to\Script.php --arg1 --arg2 --arg3
PAUSE




--=20
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message