我有一个包含内容的 php 脚本 test.php
<?php
require_once("classes/user.php");
echo "test";
?>
这是 user.php 的内容
<?php
class User {
private $data = array();
public function __set($name, $value) {
$this->data[$name] = $value;
}
public function __get($name) {
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
$trace = debug_backtrace();
trigger_error(
'Undefined property via __get(): ' . $name .
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
return null;
}
public function __isset($name) {
return isset($this->data[$name]);
}
public function __unset($name) {
unset($this->data[$name]);
}
public __construct($param) {
if(is_array($param)) $this->create($param);
else $this->id($param);
}
private id($id) { //select from database
require_once('config.php');
$pdo = new PDOConfig();
$sql = "SELECT * FROM users WHERE `id` = :id";
$q = $pdo->prepare($sql);
$q->execute(array(":id"=>$id));
$resp = $q->fetchAll();
foreach ($resp as $row) {
foreach ($row as $key=>$value) {
if(!is_int($key))
$this->data[$key] = html_entity_decode($value, ENT_QUOTES);
}
}
$pdo = null;
unset($pdo);
}
private create($arr) { //create new item from values in array and insert to db
}
public delete() {
$this->life = 0;
//update database "life" here
}
/* ##################################### */
/* !Functions */
/* ##################################### */
public projects($extra = null) {
$projects = array();
require_once('project.php');
$pdo = new PDOConfig();
$sql = "SELECT * FROM ---- WHERE `000` = :aaa";
if($extra) $sql .= " " . $extra;
$q = $pdo->prepare($sql);
$q->execute(array(":aaa"=>$this->id));
$resp = $q->fetchAll();
foreach ($resp as $row) {
$project = new Project($row['id']);
$projects[] = $project;
$project = null;
unset($project);
}
return $projects;
}
}
?>
并且永远不会打印测试,并且在 chrome 上根本不会加载页面
该网站在检索http://example.com/test.php时遇到错误。它可能因维护而停机或配置不正确。
我这辈子都想不通。谢谢它提前