我在 PHP 中的变量范围设置方面遇到了一些问题。这是我的代码结构——
<?php
$loader = new ELLoad();
$sessionid = '';
$method = $_REQUEST['m'];
if (strcasecmp($method, "getfile") == 0) {
global $loader;
$loader->load($file['text']);
global $sessionid;
$sessionid = $loader->getSessionId();
}
if (strcasecmp($method, "extract") == 0) {
$extractor = new ELExtract();
global $sessionid;
$extractor->extract($sessionid); //$session id for some reason is still ' ' here
}
来自客户端的请求序列始终是加载后提取。谁能告诉我为什么我的 $sessionid 变量可能没有得到更新吗?