我不明白下面的代码,我不知道,当我们使用session_id()之前session_start()。
<?php
if($_GET){
//defining the session_id() before session_start() is the secret
session_id($_GET['session_id']);
session_start();
echo "Data: " . $_SESSION['theVar'];
//use your data before below commands
session_destroy();
session_commit();
}else{
//common session statement goes here
session_start();
$session_id=session_id();
$_SESSION['theVar'] = "theData";
echo "your.php?session_id=" . $session_id;
}
?>
Run Code Online (Sandbox Code Playgroud)
我要你解释一下!不只是复制 php.net 的描述!
另一方面, session_id() 在哪里使用?!它的用途是什么?!先感谢您 !
我对抽象课有点困惑!我已经阅读了更多在stackoverflow和另一个网站上写的帖子,但我不明白!所以我再次看了看我的书,但我也不明白.所以请逐步分析下面的代码:
提前致谢
<?php
abstract class AbstractClass
{
abstract protected function getValue();
public function printOut() {
print $this->getValue();
}
}
class ConcreteClass1 extends AbstractClass
{
protected function getValue() {
return "ConcreteClass1";
}
}
class ConcreteClass2 extends AbstractClass
{
protected function getValue() {
return "ConcreteClass2";
}
}
$class1 = new ConcreteClass1;
$class1->printOut();
$class2 = new ConcreteClass2;
$class2->printOut();
?>
Run Code Online (Sandbox Code Playgroud)