Req #76797 [Com]: Ability to access php compiler (deprecated create_function)
| From: | spam2 at rhsoft dot net | Date: | Tue, 13 Nov 2018 18:46:25 +0000 |
| Subject: | Req #76797 [Com]: Ability to access php compiler (deprecated create_function) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217942@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76797&edit=1
ID: 76797
Comment by: spam2 at rhsoft dot net
Reported by: mageia at mokraemer dot de
Summary: Ability to access php compiler (deprecated
create_function)
Status: Wont fix
Type: Feature/Change Request
Package: *General Issues
Operating System: Linux
PHP Version: 7.2.9
Block user comment: N
Private report: N
New Comment:
it works, period, refactor and simplify your code, you can catch parse errors as any other
exception, starzing with PHP7 "Throwable"catches *anything* and if that don't happen
you have other problems - this is a bugtracker and not a support forum
---------------------------
[harry@srv-rhsoft:/downloads]$ php test.php
exception catchedParseError Object
(
[message:protected] => syntax error, unexpected end of file
[string:Error:private] =>
[code:protected] => 0
[file:protected] => /mnt/data/downloads/test.php(4) : eval()'d code
[line:protected] => 1
[trace:Error:private] => Array
(
)
[previous:Error:private] =>
)
---------------------------
[harry@srv-rhsoft:/downloads]$ cat test.php
<?php
try
{
$var = eval('nonsense');
}
catch (Throwable $e)
{
echo 'exception catched';
print_r($e);
}
Previous Comments:
------------------------------------------------------------------------
[2018-11-13 18:29:57] mageia at mokraemer dot de
same output for
Throwable
------------------------------------------------------------------------
[2018-11-13 18:27:58] spam2 at rhsoft dot net
because your code is simply wrong
catch(Throwable $e)
{
}
------------------------------------------------------------------------
[2018-11-13 18:21:50] mageia at mokraemer dot de
Test-Script:
<?php
function shutdown(){
echo 'shutdown';
}
register_shutdown_function('shutdown');
$code = '?;';
try{
$var = eval('function() { ?>' . preg_replace(['|use [\w,\s\\\\]*;|'],
'', $code) . ' <?php } ?>');
} catch (Exception $e){
echo 'exception catched';
print_r($e);
}
$php -v
PHP 7.2.11 (cli)
$php test.php
shutdown
=> I get no exception to catch!
------------------------------------------------------------------------
[2018-11-13 17:29:24] spam2 at rhsoft dot net
this is simply not true because with try-catch you have everything you need without the drawback of
mangle with the error handler
------------------------------------------------------------------------
[2018-11-13 17:09:44] requinix@php.net
> makes it impossible to check for syntax errors and handle them apropriate!
Thank you for reading the documentation, but while the sentence you identified does explain that you
can no longer handle parse errors with set_error_handler(), the sentence immediately before it told
you the new behavior:
> As of PHP 7, if there is a parse error in the evaluated code, eval() throws a
> ParseError exception.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=76797
--
Edit this bug report at https://bugs.php.net/bug.php?id=76797&edit=1