"command line"-type PHP interface?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TalonP
Forum Newbie
Posts: 6
Joined: Mon Sep 13, 2010 3:09 pm

"command line"-type PHP interface?

Post by TalonP »

Hello PHP experts!

I want to begin by referencing this website: http://www.goosh.org/
I believe that this site in particular is using mostly JS to get this done. I was wondering if I would be able to create an identical interface using HTML/PHP alone. I'm not asking for anyone to write my code, I'm more or less just wondering if anyone here has done this before, or if anyone can point me in the right direction. I'm looking for any kind of documentation on it.

I'm relatively new to PHP, but I'll pick it up fast. I'm a C/C++ developer by profession.


Thank you all for your time.
TalonP
Forum Newbie
Posts: 6
Joined: Mon Sep 13, 2010 3:09 pm

Re: "command line"-type PHP interface?

Post by TalonP »

I was just thinking, by "command line," I mean, "console" or "terminal."

I am also not looking for it to perform a Google search or anything like goosh. So I don't think I'll need AJAX or anything. I would be happy right now with a console type PHP page that displays like that and if you type "hello," or something, it would come back with "Hello there!"
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: "command line"-type PHP interface?

Post by Jade »

Um... PHP is server side only so it's not really the best choice for something like this and you'll need a ton of AJAX or Javascript to get something working. What type of actions are you looking to perform via this "command line"?
TalonP
Forum Newbie
Posts: 6
Joined: Mon Sep 13, 2010 3:09 pm

Re: "command line"-type PHP interface?

Post by TalonP »

Hi, and thanks for the response.

I am aware that PHP is server-side. I figured there would be some kind of HTML front-end. I would be happy with something as simple as:

User types "hey"

and it returns back "hello." I can work from there.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: "command line"-type PHP interface?

Post by AbraCadaver »

AJAX will probably be best, but here is a simple example that would need a lot of work and CSS styling to get it to look/align properly:

Code: Select all

<?php

$output = '';

if(isset($_POST['enter'])) {
    $output = $_POST['output'] . "\n" . $_POST['input'] . "\n";

    switch($_POST['input']) {
        case 'help':
            $output .= "You need help!";
            break;

        case 'clear':
            $output = "";
            break;

        default:
            $output .= "Invalid command!";
            break;
    }
}
?>

<html>
<head>
<title>Test</title>
</head>
<body OnLoad="document.test.input.focus();">
    <form name="test" method="post" style="width: 70%; border: 1px solid">
        <textarea rows="40" name="output" style="width: 100%; border: none" readonly><?php echo $output; ?></textarea>
        <input rows="2" type="text" name="input" style="width: 100%; border: none">
        <input type="submit" name="enter" style="visibility: hidden">
    </form>
</body>
</html>
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply