# [PATCH] sane fix for "php -c" when users do it all wrong

- Thread: https://externals.io/message/24118
- Original archive: https://news-web.php.net/php.internals/24118
- Started by Steph Fox on 2006-06-14T02:02:19+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

---

## #24118 — Steph Fox — 2006-06-14T02:02:19+00:00

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

Please can someone either apply this or give me a good reason not to?

Diffs are against PHP_5_2. Please say if you need them specifically for 
other branches.

- Steph

---

## #24119 — Andi Gutmans — 2006-06-14T04:30:13+00:00

URL: https://externals.io/message/24118#24119 · In reply to: #24118

Looks a bit weird. Can you explain the logic you are catching here?

Andi

At 07:02 PM 6/13/2006, Steph Fox wrote:
>Please can someone either apply this or give me a good reason not to?
>
>Diffs are against PHP_5_2. Please say if you need them specifically 
>for other branches.
>
>- Steph

---

## #24122 — Steph Fox — 2006-06-14T14:27:50+00:00

URL: https://externals.io/message/24118#24122 · In reply to: #24119

Hi Andi,


> Looks a bit weird. Can you explain the logic you are catching here?

It's slightly less weird than trying to read an INI file called "hello.php" 
:)

If you don't stipulate a path after -c at present CGI/CLI take the next 
element entered as being the path to the INI file. If the next element 
happens to be another switch it'll fail silently (having reverted to the 
default INI settings along the way of course). If it happens to be a 
filename (because -c was the final switch) things are worse. Zend doesn't 
check for a specific filename in the interests of flexibility, so it'll 
quite happily parse "hello.php" as an INI file. Depending on the contents of 
"hello.php" you'll see a startup crash, or the process might hang - if 
you're very lucky you'll get an ini_error message from Zend, but it's a 
misleading one in that situation since it says there's a problem in 
"hello.php".

So checking whether -c is the final switch prevents the target file being 
read as an INI file, and checking whether the next element is another switch 
prevents silent failure/INI resetting. If there's a better way to do either, 
please educate me.

- Steph

>
> Andi
>
> At 07:02 PM 6/13/2006, Steph Fox wrote:
> > […]
