Wednesday, 28 August 2013

PHP variable scoping

PHP variable scoping

I'm having some trouble with variable scoping in PHP. Here's the structure
of my code--
<?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
}
The sequence of the requests from the client is always load followed by
extract. Can anyone tell me why my $sessionid variable may not be getting
updated right?

No comments:

Post a Comment