Maison > Article > développement back-end > php static解决思路
php static
RT,用CI框架在写一个php网页,现发现static关键字不太会用,简化代码如下:
<br /> class A extends CI_Controller{<br /> private static $num = 0;<br /> public function f1(){<br /> self::$num = 1;<br /> this->load->view('v1');<br /> }<br /> public function f2(){<br /> if(self::$num === 1){<br /> this->load->view('v2'); <br /> }else{<br /> this->load->view('v3');<br /> }<br /> }<br /> }<br />