php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42438 require require_once include include_once
Submitted: 2007-08-27 08:40 UTC Modified: 2007-09-03 09:59 UTC
From: perching_eagle at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: windows xp
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: perching_eagle at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-08-27 08:40 UTC] perching_eagle at yahoo dot com
Description:
------------
the require, require_once, include, include_once operators produce unexpected results when used to import files in php v5.2.3, this problem didn't exist in the previous version i was using.

two files contain two different classes that have a parent and child relationship. if both classes are on the same file, the scripting engine  outputs the expected result. however, if they are kept in separate files and any of the four import operators are used, the scripting engine dumps jargons on the output screen.

pls. try out the example before closing, suspending or the changing the status of this complaint to bogus. Bug #41855 is the same problem as this one, but someone rushed to conclusions without testing and proclaimed it bogus.



Reproduce code:
---------------
<?php // "parent.php"
class Father{
  public $surname;
  public function __construct($name){
    $this->surname=$name;           }
            }
?>
//********************************************
//separate files
//********************************************
<?php // "child.php"
include_once("parent.php");
class Son extends Father{
  public $name;
  public function __construct($first,$last){
    parent::__construct($last);
    $this->name=$first;
}
}
$boy=new Son("john","doe");
print $boy->name;
print "<br>";
print $boy->surname;
?>

Expected result:
----------------
john
doe

Actual result:
--------------
surname=$name; } } ?>&#17930;&#29793;&#27745;&#25888;&#29298;&#29295;?&#27715;&#29537;&#8307;&#17959;&#29793;&#25960;&#10098;&#28192;&#29807;&#26144;&#30063;&#25710;&#26912;&#8302;&#14915;&#17500;&#25455;&#28021;&#28261;&#29556;&#24864;&#25710;&#21280;&#29797;&#26996;&#26478;&#23667;&#28537;&#26989;&#29472;&#29551;&#28257;&#24953;&#17500;&#29541;&#29803;&#28783;&#30556;&#29295;&#8299;&#25954;&#25454;&#23656;&#26736;&#8304;&#26982;&#25964;&#23667;&#28798;&#28776;&#25956;&#26995;&#28263;&#29285;&#28511;&#29813;&#30064;&#24436;&#28020;&#11888;&#26736;&#8304;&#28271;&#27680;&#28265;&#8293;&#2611;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-27 08:41 UTC] perching_eagle at yahoo dot com
actual output:

surname=$name; } } ?>&#17930;&#29793;&#27745;&#25888;&#29298;&#29295;?&#27715;&#29537;&#8307;&#17959;&#29793;&#25960;&#10098;&#28192;&#29807;&#26144;&#30063;&#25710;&#26912;&#8302;&#14915;&#17500;&#25455;&#28021;&#28261;&#29556;&#24864;&#25710;&#21280;&#29797;&#26996;&#26478;&#23667;&#28537;&#26989;&#29472;&#29551;&#28257;&#24953;&#17500;&#29541;&#29803;&#28783;&#30556;&#29295;&#8299;&#25954;&#25454;&#23656;&#26736;&#8304;&#26982;&#25964;&#23667;&#28798;&#28776;&#25956;&#26995;&#28263;&#29285;&#28511;&#29813;&#30064;&#24436;&#28020;&#11888;&#26736;&#8304;&#28271;&#27680;&#28265;&#8293;&#2611;
 [2007-08-27 08:43 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

I can't reproduce this. (I get the expected result..)
 [2007-08-28 00:41 UTC] perching_eagle at yahoo dot com
i tried the new extension in your post and it didn't help. 
one question?

did you try saving the two classes in seperate files?

that is when the problem arises, i even notice that by importing dummy php files created similar results, the characters that are dumped on the screen looks a lot like japanese characters.
 [2007-08-28 11:18 UTC] jani@php.net
Perhaps the reason it works for me is that I don't bother using Windows but a working OS instead. Linux. :)
 [2007-08-28 11:19 UTC] jani@php.net
Try rewriting those files of yours from scratch and set error_reporting to E_ALL and display_errors=On in your php.ini..
 [2007-08-28 18:57 UTC] perching_eagle at yahoo dot com
i followed your advice, set display_errors to On and error_reporting to E_ALL, it didn't do much help but when i set the error_reporting to E_ALL & E_STRICT the japanese characters disappeared from the output of my code when using a php editor (i use php designer), however nothing changed when i tried display my output on a browser window using apache httpd. i also noticed some comments or non-directives in the php ini file, that were not properly "commented" with ";" and correcting them still didn't help. 

i also think that in the window edition of php 5.2.3 download,  mb_string language was set to japanese by default, even for english language speakers, and those japanese characters dumped on the output screen from my code, could be error messages automatically translated into japanese.
 [2007-08-28 21:42 UTC] jani@php.net
Well, do you get readable error messages when you don't load mbstring?
(this is getting quite boring..)
 [2007-08-30 02:17 UTC] perching_eagle at yahoo dot com
not loading mbstrings didn't change anything, versions prior to 5.2.3 work well with no problem at all. 

i guess anyone that still uses a microsoft os like xp, can comfirm my complaint. well thanks jani for your help. if you have access to windows xp with php 5.2.3 installed on it, you may be able to figure out what the problem is. till then bye......
 [2007-08-30 06:01 UTC] perching_eagle at yahoo dot com
one more thing i went to google translate to check what language was being dumped on my screen, and it was only the "chinese to english" translator that was able to decipher it, the words were meaningless but i wonder why.

i hope someone can get to the bottom of this, the only solution i have right now is to manually copy all the files i would have included with the include or require directives, into one file for each class definition.

the include,require,require_once,include_once all worked for non-object oriented programs. whenever it encountered the $this-> operator in my code, especially in the constructor (just like the code in my first post), it dumps everything else after the $this-> operator on my screen.
 [2007-08-30 09:46 UTC] jani@php.net
When you installed the snapshot, did you first shutdown whatever webserver you use and delete (!!) all old installed PHP related dlls/executables BEFORE you installed the snapshot version?? 

I can't reproduce this on Windows XP (yes, I have that..) nor on Linux (preferred OS). I suspect it's simply bad installation.

 [2007-09-01 21:42 UTC] perching_eagle at yahoo dot com
i guess i have to give up, if it works on linux then i will eventually have to make the transition to linux. i did try your last suggestion and it didn't work, but i will try it a few more times and then if my problem remains unsolved, i will switch to linux earlier than i had planned.

and you may close this thread. thanks for your help.
 [2007-09-03 09:59 UTC] jani@php.net
Linux is always the best choice. :) (note: I was not able to reproduce this on _windows_ either!)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 04:01:30 2025 UTC