session_register一般使用較少了(php5 默認已經取消了session_register函數的使用, 在php5下使用,必須配置 php.ini文件,配置為:register_globle = ON,出於安全考慮,不推薦這樣做)。
下面以 設置 $_SESSION[‘login’] 的值為例:
先說 session_start()的方法
session_start(); //執行 session_start()之前 不能有任何的輸出和 html標記。一般就把它放在文件的第一行比較穩妥
//中間可以添加需要的代碼
$_SESSION[‘var’]=’this is a test’; //像設置普通變量一樣方便
?>
session_register() 的方法
<?
session_start();
session_register(‘var’);
$var=’this is a test’; //這樣就相當於設置了$_SESSION[‘var’]=’this is a test’; 是不是麻煩呢
//據說 後面如果修改$var 變量的值,$_SESSION[‘var’]的值也 不 會隨著改變,這樣看來,還不靈活
?>
寫出session_register的用法,只是讓大家有一個了解,實際使用過程中,應避免使用 session_register()函數
session_register generally use less of (php5 default has canceled the use session_register function , used under php5, you must configure the php.ini file is configured to : register_globle = ON, for security reasons, this is not recommended ) .
Here to set the $ _SESSION [‘login’] value as an example:
Let me session_start () method
session_start (); / / execute session_start () does not have any output before and html tags. General put it on the first line of the file more secure
/ / In the middle you can add the necessary code
$ _SESSION [‘Var’] = ‘this is a test’; / / variable is as easy as setting common
? >
session_register () method
session_start ();
session_register (‘var’);
$ var = ‘this is a test’; / / this is equivalent to setting the $ _SESSION [‘var’] = ‘this is a test’; are not in trouble yet
/ / It is said that back if you modify the value of the variable $ var , $ _SESSION [‘var’] value will not change as it would appear , is not flexible
? >
Write session_register usage, just let everyone have an understanding of the actual use of the process, you should avoid using session_register () function
OpenAi 官方的Strea…