Home » Php » macos – php interactive shell doesn't have any output?

macos – php interactive shell doesn't have any output?

Posted by: admin April 23, 2020 Leave a comment

Questions:

bash-3.2$ php -a
Interactive shell

php > $a = null || "hi"
php > echo $a
php > $b = "hi"
php > echo $b

As you can see here, nothing is being echoed.
Why is that?
I’m using Mac OS X lion. =\
(fresh install)

How to&Answers:

You’ve forgoten to put semicolons at the end of each line. Should be:

php > $a = null || "hi";
php > echo $a;
php > $b = "hi";
php > echo $b;

Answer:

I had the same problem:

php > echo $undefined_var

but after put ; in other line

php > ;

Result:

 Undefined variable: "undefined" in php shell code on line 2

So, is possible make this:

php > echo 123456
php > ;
php > echo 123456;