php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52970 The Bug of unset
Submitted: 2010-10-02 15:47 UTC Modified: 2010-10-13 11:15 UTC
From: ymdf at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.3 OS: windows/linux/...
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: ymdf at qq dot com
New email:
PHP Version: OS:

 

 [2010-10-02 15:47 UTC] ymdf at qq dot com
Description:
------------
Destructor if the class has a path variable $path = 'asd.php',
Uset to call the function with a class destructor that address the relative 
position will change.

Test script:
---------------
index.php
<?php
require_once 'Router.php';
$route = new Router();
echo '<br>out $rout->run:';
$route->run();
echo '<br>out $rout->destruct:';
$route->__destruct();
echo '<br>out unset($rout):';
unset($route);
?>
Router.php
class Router {
	private function __construct() {
		$this->run();
		echo '<br>in_destruct:';
		$this->__destruct();
	}
	public function run() {
		$f = 'App/controls/indexControl.php';
		if (file_exists($f)) echo ' work';
		else echo ' serror';
	}
	public function __destruct(){
	        $f = 'App/controls/indexControl'.php';
		if (file_exists($f)) echo ' work';
		else echo ' error';
	}
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-02 15:49 UTC] ymdf at qq dot com
in_run: iswork
in_destruct: iswork
out $rout->run: iswork
out $rout->destruct: iswork
out unset($rout): error
 [2010-10-02 20:17 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2010-10-02 20:17 UTC] cataphract@php.net
Sorry, I didn't understand the issue here.  The location against which relative paths are calculated changes? How?

Please provide a list of steps necessary to reproduce the problem (and write syntactically correct sentences if possible).
 [2010-10-02 20:44 UTC] ymdf at qq dot com
-Status: Feedback +Status: Open
 [2010-10-02 20:44 UTC] ymdf at qq dot com
index.php
<?
require_once 'sys/Rout.php';
$rout = new Rout();
$rout->__destruct();
unset($rout);
?>
___________________________________________________________
sys/Rout.php
<?
class Rout {
	public function __construct(){
		$this->__destruct();
	}
	public function __destruct() {
		echo '<br>',dirname(__FILE__);
		$path = 'App/controls/IndexControl.php';
		echo '<br>',$path.' ';
		echo file_exists($path) ? 'Work' : 'Change includ_path';
		require_once $path;
	}
}
?>
____________________________________________________________
output:
D:\Zend\Apache2\htdocs\Zanfsys\Zanf
App/controls/IndexControl.php Work
D:\Zend\Apache2\htdocs\Zanfsys\Zanf
App/controls/IndexControl.php Work
D:\Zend\Apache2\htdocs\Zanfsys\Zanf
App/controls/IndexControl.php Change includ_path

_________________________________________________________
error:
[02-Oct-2010 19:26:09] PHP Warning:  
require_once(App/controls/DefaultControl.php) [<a href='function.require-
once'>function.require-once</a>]: failed to open stream: No such file or 
directory in D:\Zend\Apache2\htdocs\adminsys\sys\Zanf_Rout.php on line 121
[02-Oct-2010 19:26:09] PHP Fatal error:  require_once() [<a 
href='function.require'>function.require</a>]: Failed opening required 
'App/controls/DefaultControl.php' (include_path='.') in 
D:\Zend\Apache2\htdocs\adminsys\sys\Zanf_Rout.php on line 121
 [2010-10-13 11:15 UTC] aharvey@php.net
-Status: Open +Status: Bogus -Package: Output Control +Package: *General Issues
 [2010-10-13 11:15 UTC] aharvey@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

That seems like a completely valid fatal error to me.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 12:01:33 2025 UTC