I know this might be a basic question but when I google it ,found different solutions for different php versions..in brief without wasting your time I have a. class `
class UploadHandler
{
protected $options;
public static $path;
public $prop1='';
function __construct($options=null,$x){
$this->prop1 = $x;
$this->options = array(
'script_url' => $this->getFullUrl().'/',
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).$this->getPath(),
'upload_url' => $this->getFullUrl().$this->getPath(),` ....and so on
AND methods inside it:
public function getPath()
{
return self::$path;
}
static public function setPath($autoSave)
{
self::$path = $autoSave;
}
and in another place I do this: require('upload.class.php');
.......//the above class consists inside this
UploadHandler::setPath('/files/');
why doesn't it work...??..please help me or guide me to a better tutorial
This works:
<?php
class UploadHandler {
public static $path;
public function __construct() {
}
public function getPath() {
return self::$path;
}
static public function setPath( $autoSave ) {
self::$path = $autoSave;
}
}
echo '1: ', UploadHandler::getPath(), '<br />';
UploadHandler::setPath('/files/');
echo '2: ', UploadHandler::getPath(), '<br />';
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.