I wanted to quick test a small snippet of PHP code. So, After doing a little search I setup php5-cli using synaptic on my Ubuntu machine.
Now when I tried to run
$ php -a
I get a php prompt. But I am unable to get it to work. I tried :
php > echo 'hi there!'
>
>
php > <?php echo 'hi there!' ?>
>
>
But, nothing seems to work! What am I doing wrong?
[Note: I am not very familiar with PHP]
[Update :
I wish to achieve something like :
php > $url = myurl
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
> $body = curl_exec($ch);
> curl_close($ch);
>
> echo $body
]
You need to terminate your statements with a semicolon.
php > echo "hello"
php > ;
hello
php > echo "oh!";
oh!
php >
它会像这样工作:
php -r "echo 'hello';"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.