Re: Difficulty with semicolon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Ken Robinson

On Wed, Apr 18, 2018 at 4:28 PM, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:

> Hello;
> 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
> file
> 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
> false
> was sent: EVEN though the file WAS actually created. It appears that the
> semi
> colon caused the false value to be converted to true and the error was
> sent.
> 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
> issued
> 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.
> JK
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux