Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,137 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,058 people online right now. Registration is fast and FREE... Join Now!




Troble using php with php cli

 
Reply to this topicStart new topic

Troble using php with php cli

Israel
6 Mar, 2007 - 10:40 PM
Post #1

D.I.C Addict
Group Icon

Joined: 21 Nov, 2004
Posts: 604


Dream Kudos: 175
My Contributions
Ok, I'm new to php cli. I've tried to just create this script:
CODE
<?php print "Hello World!"; ?>

But I get all this extra stuff from the cli and I can't save the file?
CODE
root@Me:/home/Israel# php -a -s
Interactive mode enabled

<code><span style="color: #000000">
<?php print "Hello World!"; ?>
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">print&nbsp;</span><span style="color: #DD0000">"Hello&nbsp;World!"</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;<br />Filename:HelloWorld.php

User is offlineProfile CardPM
+Quote Post

snoj
RE: Troble Using Php With Php Cli
7 Mar, 2007 - 05:43 AM
Post #2

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
Try using php -f filename_and_path.php?
User is offlineProfile CardPM
+Quote Post

Israel
RE: Troble Using Php With Php Cli
7 Mar, 2007 - 07:53 AM
Post #3

D.I.C Addict
Group Icon

Joined: 21 Nov, 2004
Posts: 604


Dream Kudos: 175
My Contributions
Hmmm.... I got it to stop adding all that extra code by turning off the -s switch. I misunderstood the man page thinking this would high-light the codes on the command line in color like Notepad++ or one of those text-editors. I see now that it just adds code to make the output of the text in your php file in colors. By turning off that switch I could then input my code and the command line returned: "Hello World!". But when I tried adding the -f /home/file
I got this...
CODE
root@Me:/home/Me# php -f /home/Israel/hello.php
Could not open input file: /home/Israel/hello.php
root@Me:/home/Me# php -a -f /home/Israel/hello.php
Interactive mode enabled

Could not open input file: /home/Israel/hello.php


Do I need to create a blank php file first and edit it from the Command Line? Can't you just start from the command line?

This post has been edited by Israel: 7 Mar, 2007 - 07:55 AM
User is offlineProfile CardPM
+Quote Post

snoj
RE: Troble Using Php With Php Cli
7 Mar, 2007 - 10:42 AM
Post #4

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
Yeah, you'd need to a file named "hello.php" to do what you're doing currently since you'd need php code to do stuff.

Now to execute code written in the command line check out this code snippet. It delves into how to do such a thing. wink2.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 10:40PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month