48

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)

1
  • 1
    too late to comment, but use psysh Commented Apr 1, 2016 at 16:20

2 Answers 2

73

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;
Sign up to request clarification or add additional context in comments.

Comments

4

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;

1 Comment

Or, if you're like me, I had the closing semi-colon, but I started testing with an empty string. It printed an empty string, alright. Looks like no output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.