📜  js 数据 php - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:03.410000             🧑  作者: Mango

代码示例1
// In your controller
if(isset($_POST)){

    $obj = new MyObject();
    $obj->name = $_POST['name'];
    $obj->date = date("Y-m-d");
    $obj->validatePost();
    $obj->update();

    $result = $obj->getData();
    return $result;

}


// Your model
class MyObject {

    public $name;
    public $date;

    public function validatePost(){
        if($this->name == null){
            // print error
        }
    }

    public function update(){
        // database cheets
    }

    public function getData(){
        return $json;
    }

}