Re: [PHP] Difficulty with semicolon
- Date: Wed, 18 Apr 2018 16:38:06 -0400
- From: Ken Robinson <kenrbnsn@xxxxxxxxx>
- Subject: Re: [PHP] Difficulty with semicolon
It's not a syntax error, so no error message is needed. The semi-colon just
ends the statement. At that point the value of the if statement is not
used. The next statement is executed as though there was no if statement
there. Maybe a warning message could be issued in this case, but it
wouldn't stop the program from running.
On Wed, Apr 18, 2018 at 4:28 PM, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
> This is the second time I have had to deal with this issue.
> It is the result of my own typing errors. But I thought it would
> be worthwhile sharing the implicit problem.
> You may notice the line marked '//<<<' There is a semicolon immediately
> following the closing ')'.
> This is part of a function to create a directory with a default index.php
> This code would not run if the directory had not been created successfully.
> What happened was that the error implied by file_put_contents returning
> was sent: EVEN though the file WAS actually created. It appears that the
> colon caused the false value to be converted to true and the error was
> Or it just canceled the conditional test and the error block was run with
> out it.
> (I didn't think it was possible).
> So, the take away is that it would be worthwhile for a syntax error to the
> in this case. I can't think of any conditional or looping construct that
> would use
> a semicolon at this location usefully. And lord knows that if you leave
> one out
> where it needs to be, you hear about it.
> $_indTxt = "<?php\n/* code */;\n"."?".">";
> if(file_put_contents($_tar."/index.php", $_indTxt) === false); // <<<
> $_out['error'] = $_errHead." file named ".$_tarShrt."/index.php file
> not created";
> return $_out;
> Thanks for time and attention.
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php