Alternative to form for user response?

It’s been awhile since I’ve dabbled in PHP.

I want to (a) populate a screen for the user to view, (b) ask the user if she wants to print that screen then (c) ask if the user wants another populated screen. If I could get these responses (b) and (c) without the hassle of forms, I’d use a do … while and be able to retain my local data.

I’ve tried “readline”, but I don’t think it works on Windows [aren’t we surprised?]. The alternative in [http://php.net/manual/en/function.readline.php] (http://php.net/manual/en/function.readline.php) contains this code.

<?php if (PHP_OS == 'WINNT') { echo '$ '; $line = stream_get_line(STDIN, 1024, PHP_EOL); } else { $line = readline('$ '); } ?>

I assume it works, but isn’t there an easier way?

I see you have got this code from the PHP manual. I’m not sure how much simpler it could be.

The Symfony console component might have a better api for that.

Thanks. But Symfony looks to be a more robust solution than this Q&D justifies.

Yeah. More probably it’s my design that’s lacking. Like I wrote, it’s been awhile. Thanks for your prompt response.

I was referring to using just the console component to manipulate user input on the command line and possibly manage screens.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.