# CLI php -r requires final ;

- Thread: https://externals.io/message/22747
- Original archive: https://news-web.php.net/php.internals/22747
- Started by Richard Lynch on 2006-04-14T03:49:33+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22747 — Richard Lynch — 2006-04-14T03:49:33+00:00

URL: https://externals.io/message/22747#22747

This is such minutiae, but I needed a break...

The docs say final ?> is not needed, and final ; is not needed:

http://php.net/manual/en/language.basic-syntax.instruction-separation.php

It does not address what happens if BOTH are missing, however.

It would seem that with both missing...

-bash-2.05b$ cat temp.php
<?php
        echo 'hello'
-bash-2.05b$
php -q temp.php

you get a syntax error:

Parse error: parse error, unexpected $end, expecting ',' or ';'

This is fine, of course.

We'll call it a feature, even, I guess.

But, for me, it feels decidedly "odd" when I do:

php -r "echo 'hello'"

and get:
Parse error: parse error, unexpected $end, expecting ',' or ';'

I mean, for some reason, I just expected that the "optional"
semi-colon at the end was, well, optional...

I mean, -r runs the code without me needing to add <?php and ?>

It's not like I'm relying on the optional ?> at the end of a file
feature.

It's a different animal.

php -r is "adding in" both <?php and ?> for me, in my mind, at least.

I just sort of expected that the -r getting rid of <?php and ?> didn't
"count" against the ?> OR ; being optional, and I figured the ; was
still optional.

Am I being too petty? :-^

I'm not filing this as bug report without some feedback, that's for sure!

Actually, I'm just interested to see how others think about this.

I don't even like leaving off ?> nor ; in PHP source code.  I think
it's just a sign of sloppy coding -- even if it does mean that I can't
get that perfectly-align HTML coming out.

-- 
Like Music?
http://l-i-e.com/artists.htm

---

## #22748 — Steph Fox — 2006-04-14T03:53:58+00:00

URL: https://externals.io/message/22747#22748 · In reply to: #22747

The final ; is needed with php -r.  It's even documented somewhere :)

----- Original Message ----- 
From: "Richard Lynch" <ceo@l-i-e.com>
To: <internals@lists.php.net>
Sent: Friday, April 14, 2006 5:49 AM
Subject: [PHP-DEV] CLI php -r requires final ;


> This is such minutiae, but I needed a break...
> 
> The docs say final ?> is not needed, and final ; is not needed:
> 
> http://php.net/manual/en/language.basic-syntax.instruction-separation.php
> 
> It does not address what happens if BOTH are missing, however.
> 
> It would seem that with both missing...
> 
> -bash-2.05b$ cat temp.php
> <?php
>        echo 'hello'
> -bash-2.05b$
> php -q temp.php
> 
> you get a syntax error:
> 
> Parse error: parse error, unexpected $end, expecting ',' or ';'
> 
> This is fine, of course.
> 
> We'll call it a feature, even, I guess.
> 
> But, for me, it feels decidedly "odd" when I do:
> 
> php -r "echo 'hello'"
> 
> and get:
> Parse error: parse error, unexpected $end, expecting ',' or ';'
> 
> I mean, for some reason, I just expected that the "optional"
> semi-colon at the end was, well, optional...
> 
> I mean, -r runs the code without me needing to add <?php and ?>
> 
> It's not like I'm relying on the optional ?> at the end of a file
> feature.
> 
> It's a different animal.
> 
> php -r is "adding in" both <?php and ?> for me, in my mind, at least.
> 
> I just sort of expected that the -r getting rid of <?php and ?> didn't
> "count" against the ?> OR ; being optional, and I figured the ; was
> still optional.
> 
> Am I being too petty? :-^
> 
> I'm not filing this as bug report without some feedback, that's for sure!
> 
> Actually, I'm just interested to see how others think about this.
> 
> I don't even like leaving off ?> nor ; in PHP source code.  I think
> it's just a sign of sloppy coding -- even if it does mean that I can't
> get that perfectly-align HTML coming out.
> 
> -- 
> Like Music?
> http://l-i-e.com/artists.htm
> 
> -- 
> 
> 
> 
> 
> __________ NOD32 1.1380 (20060125) Information __________
> 
> This message was checked by NOD32 antivirus system.
> http://www.eset.com

---

## #22749 — Edin Kadribasic — 2006-04-14T03:54:40+00:00

URL: https://externals.io/message/22747#22749 · In reply to: #22747

php -r is equivalent of calling eval() in php code. See 
http://php.net/eval for details.

Edin


Richard Lynch wrote:
> This is such minutiae, but I needed a break...
> 
> The docs say final ?> is not needed, and final ; is not needed:
> 
> http://php.net/manual/en/language.basic-syntax.instruction-separation.php
> 
> It does not address what happens if BOTH are missing, however.
> 
> It would seem that with both missing...
> 
> -bash-2.05b$ cat temp.php
> <?php
>         echo 'hello'
> -bash-2.05b$
> php -q temp.php
> 
> you get a syntax error:
> 
> Parse error: parse error, unexpected $end, expecting ',' or ';'
> 
> This is fine, of course.
> 
> We'll call it a feature, even, I guess.
> 
> But, for me, it feels decidedly "odd" when I do:
> 
> php -r "echo 'hello'"
> 
> and get:
> Parse error: parse error, unexpected $end, expecting ',' or ';'
> 
> I mean, for some reason, I just expected that the "optional"
> semi-colon at the end was, well, optional...
> 
> I mean, -r runs the code without me needing to add <?php and ?>
> 
> It's not like I'm relying on the optional ?> at the end of a file
> feature.
> 
> It's a different animal.
> 
> php -r is "adding in" both <?php and ?> for me, in my mind, at least.
> 
> I just sort of expected that the -r getting rid of <?php and ?> didn't
> "count" against the ?> OR ; being optional, and I figured the ; was
> still optional.
> 
> Am I being too petty? :-^
> 
> I'm not filing this as bug report without some feedback, that's for sure!
> 
> Actually, I'm just interested to see how others think about this.
> 
> I don't even like leaving off ?> nor ; in PHP source code.  I think
> it's just a sign of sloppy coding -- even if it does mean that I can't
> get that perfectly-align HTML coming out.
