php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41232 Eval failing on calls to class methods
Submitted: 2007-04-29 23:14 UTC Modified: 2007-04-30 22:40 UTC
From: Antoniocs at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.2.1 OS: Windows XP sp2
Private report: No CVE-ID: None
 [2007-04-29 23:14 UTC] Antoniocs at gmail dot com
Description:
------------
I am trying to use output control functions to replace text with processed pages. So I am using eval on a callback function

Reproduce code:
---------------
//page_parser.php file (small class to parse pages and replace with something set by me)
URL: http://privatepaste.com/9818gOaFnI

//teste_parser.php file (file that calls the class to use it to replace a string that I set with the contents of a php file)
URL: http://privatepaste.com/32658Bx95B

//teste_parser_2.php file (file that contains the php code to be processed by eval. Later this will replace the string set by me
URL: http://privatepaste.com/0c1Ev1CTKA

Expected result:
----------------
The teste() method from the class bla to show it's echo (which is a simple Hello)

Actual result:
--------------
Nothing appears. The page is blank. All because I call a class method.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-30 13:22 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-04-30 14:44 UTC] Antoniocs at gmail dot com
I set all the code you would need in the paste site.

Just run the teste_parser.php file and it will call the rest
 [2007-04-30 16:05 UTC] tony2001@php.net
Please provide a SHORT but complete reproduce case in ONE short script. I believe HTML or several scripts are not required for this.
Thank you.
 [2007-04-30 16:06 UTC] Antoniocs at gmail dot com
Here are the source files: http://www.antoniocs.org/eval_test.rar

Unpack, and run teste_parser.php
 [2007-04-30 16:43 UTC] tony2001@php.net
<html>
<head>
</head>

<body>
Hey!! Tudo bem??????<br>
<br>
                                                        OLAS<br>
Notice: Use of undefined constant TESTE - assumed 'TESTE' in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 3
TESTE
iojdsfoijdoidsd<br><br>1177951395
Notice: Undefined variable: BLA in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 12

Hello hello
</body>
</html>
 [2007-04-30 16:46 UTC] Antoniocs at gmail dot com
I commented the $blas->teste();

If you remove the comments from that line you will get a blank page
 [2007-04-30 22:00 UTC] tony2001@php.net
It's commented out (and I get the output I pasted earlier).
I'm asking you again: please provide a SHORT but compete reproduce script. Take these scripts, merge them into the one script and remove everything not necessary to reproduce the problem.
That'll help you to find your bugs in the code.
Also please try to execute it in console and look into the error log.
The "I see an empty screen" thing is completely useless.
 [2007-04-30 22:04 UTC] Antoniocs at gmail dot com
Uncomment the line!! 

I can't put them all together because this is suppose to work like this.
The page appears blank when I call the method

Change //$blas->teste();
To $blas->teste();
 [2007-04-30 22:12 UTC] tony2001@php.net
Debug your code.
The code you're trying to eval() in the output handler is wrong.
 [2007-04-30 22:28 UTC] Antoniocs at gmail dot com
The code is fine!! The way in which I call it is what is breaking up the  code. But that shouldn't happen!! 

The $bla->teste() method is causing the script to somehow screw up, but there is nothing wrong in the class
 [2007-04-30 22:32 UTC] tony2001@php.net
As long as you're unable to provide a short reproduce code, it's obvious that the problem is in your code.
Please keep this report marked as bogus, thank you.
 [2007-04-30 22:40 UTC] Antoniocs at gmail dot com
This is not bogus!!

Go here and see the script running

http://www.antoniocs.org/eval_test/

http://www.antoniocs.org/eval_test/eval_test.rar <-- download the code here

When you run the code you will only get the <html> tag which is before ob_start. Eval screws up everything
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC