Bug #63026 [Com]: require_once error

2012-09-12 Thread ian dot xspace at yahoo dot cn
Edit report at https://bugs.php.net/bug.php?id=63026edit=1

 ID: 63026
 Comment by: ian dot xspace at yahoo dot cn
 Reported by:ian dot xspace at yahoo dot cn
 Summary:require_once error
 Status: Feedback
 Type:   Bug
 Package:*Compile Issues
 Operating System:   windows 7
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
关键是这种情况下我调用很多类都成功了,不是应该失败的吗,下面才是正确写法
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);


Previous Comments:

[2012-09-12 10:30:46] re...@php.net

“$obj = $this-loadCS('M.share_model');//调用其它类
   
//你可以多调用几个类,在上面错误写法情况下,有的类可以调用成功,有的失败
   //sysModule 
里的对应关系,应该这么写'C'=CTRLS,后者无需引号
”
require_once的路径是直接拼的,而且不是autoload,
他这里没有其他的例子,如果部分类名大小写错了,就会出现部分类找不到的情况。

在require前增加个检查就能确认或者排除这个问题了


[2012-09-12 10:25:08] larue...@php.net

你从哪里看出来和大小写有关系的?


[2012-09-12 10:15:04] re...@php.net

看你这情况,有可能是你的大小写问题, 
你是直接require_once的,如果大小写错了是有问题的。
为了好调试,你可以在require_once 前加一个if(!file_exists($file) 
{die($file not found)}
检查一下。 你确认一下文件的确存在吧。

同时,是在不行,把你的代码完整打包传到某个地方吧。。


[2012-09-12 02:03:08] larue...@php.net

那些类名可以正确加载 ,那些类名不可以?  你举个例子?


[2012-09-12 01:56:19] ian dot xspace at yahoo dot cn

//init.php 定义网站目录
/***网站目录定义***/
define('THEME', 'default');
//define('TEMP', WEB_ROOT.DS.'temp');
//define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
//define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//SYS.php  
sysModule函数里的对应关系为错误写法,正确写法应该是'M'=MODELS后者无需单引号
class SYS
{
//sysModule系统目录映射
private function sysModule()
{
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
}
//getSys获取相应配置
public static function getSys($fun)
{
return self::$fun();
}
}
//common.php 其中一个函数,加载所需要的类
class Common
{
//loadCS
protected function loadCS($cs)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //直接定位   
require_once($moArr[$type].DS.{$csName}.php);
//  switch($type)  以上将会获取更快执行速度
//  {
//  case 'M':
//  require_once(MODELS.DS.$csName.php);
//  break;
//  case 'V':
//  require_once(VIEWS.DS.$csName.php);
//  break;
//  case 'C':
//  require_once(CTRLS.DS.$csName.php);
//  break;
//  case 'L':
//  require_once(LIBS.DS.$csName.php);
//  break;
//  case 'P':
//  require_once(PLNS.DS.$csName.php);
//  break;
//  case 'H':
//  require_once(HLP.DS.$csName.php);
//  break;
//  default:
//  JS::willJS('alertMsg', '调用失败!');
//  }
$CS

Bug #63026 [Com]: require_once error

2012-09-11 Thread ian dot xspace at yahoo dot cn
Edit report at https://bugs.php.net/bug.php?id=63026edit=1

 ID: 63026
 Comment by: ian dot xspace at yahoo dot cn
 Reported by:ian dot xspace at yahoo dot cn
 Summary:require_once error
 Status: Feedback
 Type:   Bug
 Package:*Compile Issues
 Operating System:   windows 7
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

早说啊,我还以为都是外国人呢。
//定义网站跟目录 init.php
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//定义网站的其它目录
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
//下面是我写的一个类 sys.php
class SYS
{

//这个是每个目录对应的简写,但是这是错误写法,可在后期的程序调用中居然有的
//可以成功有的失败了  $moArr = SYS::getSys('sysModule');
//require_once($moArr[$type].DS.{$csName}.php); 这样可以直接
//引入所需要的文件,避免使用switch浪费时间
/*
//  switch($type)  以上将会获取更快执行速度
//  {
//  case 'M':
//  require_once(MODELS.DS.$csName.php);
//  break;
//  case 'V':
//  require_once(VIEWS.DS.$csName.php);
//  break;
//  case 'C':
//  require_once(CTRLS.DS.$csName.php);
//  break;
//  case 'L':
//  require_once(LIBS.DS.$csName.php);
//  break;
//  case 'P':
//  require_once(PLNS.DS.$csName.php);
//  break;
//  case 'H':
//  require_once(HLP.DS.$csName.php);
//  break;
//  default:
//  JS::willJS('alertMsg', '调用失败!');
//  }
   */
   //这里是系统目录对应的单词简写,但是这是错误写法
   //正确写法应该是  'M'=MODELS 
后面无需加单引号(虽然是错误写法但是使用的时候
   //有的可以正常使用有的不能正常使用)
private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

public static function getSys($fun)
{
return self::$fun();
}
}

//common.php 其它程序共享类
class Common
{
   //类中的一个函数用于调用所需要的其他类
   public function loadSomeClass($type)
   {
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //find module
require_once($moArr[$type].DS.{$csName}.php);
   }
}

//index.php 比如在index.php页面里调用其他类文件
class Index
{
   public function __construct()
   {
 require_once 'common.php';
 $com = new Common();
 
$com-loadSomeClass('M.db_model');//引入这个类文件或者mvc里的任何一个文件
//问题就出在这里  'M'='MODELS', 
这种写法是有错的,但是调用loadSomeClass
//时候居然有的类可以正确加载而有的类不能正确加载
   }
}
new Index();

//要是还看不明名,你告诉我从哪里上传文件啊,或者我的QQ是995668790,以前我在你的博客里和你
聊过ian,就说有bug的


Previous Comments:

[2012-09-10 07:53:37] larue...@php.net

你用中文描述吧, 我实在看不懂你说什么错误 
另外, 请提供一个可以正常运行的可重试脚本. 
(you can re-describe this problem in chinese, previous one is hard to read).

thanks


[2012-09-10 07:44:44] ian dot xspace at yahoo dot cn

private function sysModule()
{
//error writing 错误写法
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
//right wring 正确写法
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);

}

//common.php load some calss file
//Assume  $type = 'M.className';
function loadSomeClass($type)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule

Bug #63026 [Com]: require_once error

2012-09-11 Thread ian dot xspace at yahoo dot cn
Edit report at https://bugs.php.net/bug.php?id=63026edit=1

 ID: 63026
 Comment by: ian dot xspace at yahoo dot cn
 Reported by:ian dot xspace at yahoo dot cn
 Summary:require_once error
 Status: Feedback
 Type:   Bug
 Package:*Compile Issues
 Operating System:   windows 7
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

//init.php 定义网站目录
/***网站目录定义***/
define('THEME', 'default');
//define('TEMP', WEB_ROOT.DS.'temp');
//define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
//define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//SYS.php  
sysModule函数里的对应关系为错误写法,正确写法应该是'M'=MODELS后者无需单引号
class SYS
{
//sysModule系统目录映射
private function sysModule()
{
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
}
//getSys获取相应配置
public static function getSys($fun)
{
return self::$fun();
}
}
//common.php 其中一个函数,加载所需要的类
class Common
{
//loadCS
protected function loadCS($cs)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //直接定位   
require_once($moArr[$type].DS.{$csName}.php);
//  switch($type)  以上将会获取更快执行速度
//  {
//  case 'M':
//  require_once(MODELS.DS.$csName.php);
//  break;
//  case 'V':
//  require_once(VIEWS.DS.$csName.php);
//  break;
//  case 'C':
//  require_once(CTRLS.DS.$csName.php);
//  break;
//  case 'L':
//  require_once(LIBS.DS.$csName.php);
//  break;
//  case 'P':
//  require_once(PLNS.DS.$csName.php);
//  break;
//  case 'H':
//  require_once(HLP.DS.$csName.php);
//  break;
//  default:
//  JS::willJS('alertMsg', '调用失败!');
//  }
$CS = ucfirst($csName);
return new $CS();
}
}

//index.php 首页调用其它类
//Index
class Index extends IAN_C
{
//__construct
public function __construct()
{
   $obj = $this-loadCS('M.share_model');//调用其它类
   
//你可以多调用几个类,在上面错误写法情况下,有的类可以调用成功,有的失败
   //sysModule 
里的对应关系,应该这么写'C'=CTRLS,后者无需引号
}

}
new Index

//大哥你要是再看不明白,我也没辙了


Previous Comments:

[2012-09-12 01:48:03] ian dot xspace at yahoo dot cn

早说啊,我还以为都是外国人呢。
//定义网站跟目录 init.php
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//定义网站的其它目录
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
//下面是我写的一个类 sys.php
class SYS
{

//这个是每个目录对应的简写,但是这是错误写法,可在后期的程序调用中居然有的
//可以成功有的失败了  $moArr = SYS::getSys('sysModule');
//require_once($moArr[$type].DS.{$csName}.php); 这样可以直接
//引入所需要的文件,避免使用switch浪费时间
/*
//  switch($type)  以上将会获取更快执行速度
//  {
//  case 'M':
//  require_once(MODELS.DS.$csName.php);
//  break;
//  case 'V':
//  require_once(VIEWS.DS.$csName.php);
//  break;
//  case 'C':
//  require_once(CTRLS.DS.$csName.php);
//  break;
//  case 'L':
//  require_once(LIBS.DS.$csName.php);
//  break;
//  case 'P':
//  require_once(PLNS.DS.$csName.php

Bug #63026 [Com]: require_once error

2012-09-10 Thread ian dot xspace at yahoo dot cn
Edit report at https://bugs.php.net/bug.php?id=63026edit=1

 ID: 63026
 Comment by: ian dot xspace at yahoo dot cn
 Reported by:ian dot xspace at yahoo dot cn
 Summary:require_once error
 Status: Feedback
 Type:   Bug
 Package:*Compile Issues
 Operating System:   windows 7
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

private function sysModule()
{
//error writing 错误写法
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
//right wring 正确写法
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);

}

//common.php load some calss file
//Assume  $type = 'M.className';
function loadSomeClass($type)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //find module
require_once($moArr[$type].DS.{$csName}.php); 
//Error wording actually some successful and some not successful
//在错误写法下居然有的能成功有的不能成功
}


Previous Comments:

[2012-09-07 17:19:21] larue...@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.




[2012-09-07 05:28:30] ian dot xspace at yahoo dot cn

Description:

?php 
//OS: win7  php:5.3.16 mysql:5.5
//such as  [Some code snippets]
//Assume  WEB_ROOT = 'E:/www';
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//define the web system directory
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//define  associate
/*Error writing   */
class SYS
{
private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

public static function getSys($fun)
{
return self::$fun();
}   
}   

//common.php load some calss file
//Assume  $type = 'M.className';
function loadSomeClass($type)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //find module
require_once($moArr[$type].DS.{$csName}.php);
}

//bugs: In accordance with the above wording some successful and some can not 
successfully  ?

/*
private function sysModule()
{
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
} 
 */

?

Test script:
---
?php 
//OS: win7  php:5.3.16 mysql:5.5
//such as  [Some code snippets]
//Assume  WEB_ROOT = 'E:/www';
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//define the web system directory
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//define  associate
/*Error writing   */
class SYS
{
private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

public static function getSys($fun)
{
return self::$fun();
}   
}   

//common.php

[PHP-BUG] Bug #63026 [NEW]: require_once error

2012-09-06 Thread ian dot xspace at yahoo dot cn
From: ian dot xspace at yahoo dot cn
Operating system: windows 7
PHP version:  5.3.16
Package:  *Compile Issues
Bug Type: Bug
Bug description:require_once error

Description:

?php 
//OS: win7  php:5.3.16 mysql:5.5
//such as  [Some code snippets]
//Assume  WEB_ROOT = 'E:/www';
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//define the web system directory
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//define  associate
/*Error writing   */
class SYS
{
private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

public static function getSys($fun)
{
return self::$fun();
}   
}   

//common.php load some calss file
//Assume  $type = 'M.className';
function loadSomeClass($type)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //find module
require_once($moArr[$type].DS.{$csName}.php);
}

//bugs: In accordance with the above wording some successful and some can
not successfully  ?

/*
private function sysModule()
{
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
} 
 */

?

Test script:
---
?php 
//OS: win7  php:5.3.16 mysql:5.5
//such as  [Some code snippets]
//Assume  WEB_ROOT = 'E:/www';
define('WEB_ROOT', strtr(dirname(__FILE__), '\\', '/'));
//define the web system directory
define('TEMP', WEB_ROOT.DS.'temp');
define('LIBS', WEB_ROOT.DS.'libs');
define('VIEWS', WEB_ROOT.DS.'views');
define('LOGS', VIEWS.DS.'logs');
define('DYN', VIEWS.DS.'dynamic');
define('HLP', WEB_ROOT.DS.'helpers');
define('PLNS', WEB_ROOT.DS.'plugins');
define('CONFS', WEB_ROOT.DS.'configs');
define('MODELS', WEB_ROOT.DS.'models');
define('CTRLS', WEB_ROOT.DS.'controls');
//define  associate
/*Error writing   */
class SYS
{
private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

public static function getSys($fun)
{
return self::$fun();
}   
}   

//common.php load some calss file
//Assume  $type = 'M.className';
function loadSomeClass($type)
{
$csName = substr($cs, 2);
$type = strtoupper(strtok($cs, '.'));
$moArr = SYS::getSys('sysModule'); //find module
require_once($moArr[$type].DS.{$csName}.php);
}

//bugs: In accordance with the above wording some successful and some can
not successfully  ?

/*
private function sysModule()
{
return array(
'M'=MODELS, 'V'=VIEWS,
'C'=CTRLS, 'L'=LIBS,
'P'=PLNS, 'H'=HLP
);
} 
 */

?

Expected result:

private function sysModule()
{
return array(
'M'='MODELS', 'V'='VIEWS',
'C'='CTRLS', 'L'='LIBS',
'P'='PLNS', 'H'='HLP'
);
}

error writing!
why require_once  some successful and some error


-- 
Edit bug report at https://bugs.php.net/bug.php?id=63026edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63026r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63026r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=63026r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=63026r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=63026r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=63026r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=63026r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=63026r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=63026r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=63026r=support
Expected