有什么办法可以像函数那样“调用”一个对象?
假设我们具有以下功能:
<?php
$dbname = "bps";
$host = "localhost";
$user = "root";
$pass = "";
$conn = new mysqli($host,$user,$pass,$dbname);
//check for error
if ($conn->connect_error){
die("Connection Failed!!");
}
$id = intval($_GET['id']);
// echo $id;die;
$results = mysql_query("SELECT * FROM bps_registration_newregistration WHERE id=$id");
while ($row= mysql_fetch_array($results))
{
$registration_date = $row['registration_date'];
echo $id; die;//Outputs: 2
}
?>
我可以这样写一些代码吗??
function sayHello() {
console.log('hello :)');
}
sayHello();
// Output: hello :)
P.S。我知道这个问题很奇怪,但是我对是否有可能做这样的事情很感兴趣:)