In PHP::, ->, self, $this operators

When accessing member variables or methods in a PHP class, if the referenced variable or method is declared as const (defining a constant) or static (declaring static), then you must use the operator::, otherwise if the referenced variable or method If the method is not declared const or static, the operator -> must be used. ​ ​ In addition, if you access a const or static variable or method from inside the class, you must use the self-referential self. On the contrary, if you access a non-const or static variable or method from the inside of the class, you must use the self-referenced $this. $this instance The code is as follows <?php // this is a pointer to the current object class test_this{ private $content; //Define variables ​ Function __construct($content){ //Define constructor             $this->cOntent= $content; } Function __destruct(){}//Define destructor ​ Function printContent(){//Define printing function echo $this->content.’‘; } } $test=new test_this(‘Welcome to Beijing!’); //Instantiated object $test->printContent();//Welcome to Beijing! ​ ::Instructions The code is as follows //parent is a pointer to the parent class class test_parent{ //base class Public $name; //Define name Parent class members need to be defined as public before they can be called directly using this in the inherited…

In PHP, if a class is not instantiated, will it occupy server resources? Solutions

In PHP, if a class is not instantiated, will it occupy server resources? In PHP, if a class is not instantiated, will it occupy server resources? Because I want to create a file, put all the classes in one file, and include this file when needed ——Solution– ——————When the class file is loaded, php will compile the classWhen the class is instantiated, php will The corresponding object allocates memoryWhen the object is executed, php will allocate memory for the properties involved ——Solution——————–Me Of course not, but this question is relative. Although you do not instantiate, it brings a new problem Which one do you think is Include N class documents or Include 1 class document? Taking up server resources? Of course, this occupation may be ignored. You can do this, but I don’t recommend it. It will only cause you more trouble in terms of maintenance and code readability. One final reminder is whether you use __autoload. If not then do what you want.

In PHP, usage (example) of http_post_data and http_put_data? Solutions

In PHP, usage (example) of http_post_data and http_put_data? Hello, how to use http_post_data and http_put_data in PHP (a small example), thank you… —– -Solution——————– Manual manual. . http://www.php.net/manual/en/function.http-post-data.phpThis is roughly the usage. There are many parameters that can be configured $url = “http://www.renren.com/PLogin.do”;$data = arry(’email’=>’abcd @yahoo.com.cn’,’password’=>’****’);$respOnse= http_post_data($url,$data);if($respOnse===false) { echo “failure notice!”;}else echo $response; ——Solution——————– Prompt that the function http_post_data() cannot be found You have not loaded the corresponding extension libraryIt seems that the function http_post_data() is a php_http extensionI will give you a reference, I hope it will be helpful to you Usefulhttp://liero.me/?p=729

In php, js verifies registration conditions, and issues related to Chinese garbled characters when displaying prompt information

In php, js verifies registration conditions, and the problem of Chinese garbled characters when displaying prompt informationjs files are written separately. Simple information is filled in when verifying login, such as the length of the registration name must be greater than 6 digits, whether the email format is correct, etc. But when the prompt information displayed in the div layer is garbled, how to solve it? Picture attached. . I hope you can give me some advice. . Thanks. . . ——Solution——————– Can’t see the picture. As long as the coding is unified, there will basically be no problem. ——Solution——————– You change the encoding of all files including js files to utf-8editplus is to set the page encoding, dw is the page attributeAdd in the display page

In php, check whether a downloaded file with the same name already exists in the directory of the downloaded file.

Check in php whether an uploaded file with the same name already exists in the directory of the uploaded file Check whether an uploaded file with the same name already exists in the directory where you uploaded the file ? function searchFile($path,$file){ $file_array=array(); //Storage array of file names $folder_array=array(); //Storage array of directory names $all_array=array(); //array to store all paths if(is_dir($path)){ //Check whether the file directory exists $H = @ opendir($path); while(false !== ($_file=readdir($H))){ //Retrieve directory if(is_dir($path.”/”.$_file) && $_file != “.” && $_file!=”..” && $_file!==”Thumbs.db”){ if(eregi(‘/’.$file,’/’.$_file)){ array_push($folder_array,$path.”/”.$_file); } searchFile($path.”/”.$_file,$file); //Retrieve files }elseif(is_file($path.”/”.$_file) && $_file!=”.” && $_file!=”..” && $_file!==”Thumbs.db”){ echo $_file; echo ”; //$_file = auto_charset($_file,’utf-8′,’gbk’); if(eregi(‘/’.$file,’/’.$_file)){ array_push($file_array,$path.”/”.$_file); return ‘yes’; //The file exists } } } //$this->all_array[“folder”]=$this->folder_array; //$this->all_array[“file”]=$this->file_array; closedir($H); return ‘no’; //does not exist }elseif(is_file($path)){ if(eregi($file,$path)){ //$this->all_array[“file”]=$path; return ‘yes’; //The file exists } else { return ‘no’; //The file does not exist } }else{ return ‘no’; //The file does not exist } } ? ?

In php, isset() functions and examples

In php, the function and examples of isset() ————————————————– Check if the variable is defined ——————————————— ——– Determine whether the variable has been configured. ______________________________________________________________________________issetDetermines whether the variable has been set. Syntax: int isset(mixed var);Return value: integerFunction type: PHP system functionContent descriptionThis function is used to test variables Has it been set? If the variable already exists, a true value is returned. Otherwise a false value is returned. Usage examples<?php$a = “test”;echo isset($a); // trueunset($a );echo isset($a); // false?>

In php, how to use MSClass (ClassOfMarqueeScroll universal uninterrupted scrolling JS encapsulation class)

In php, how to use MSClass (Class Of Marquee Scroll universal uninterrupted scrolling JS encapsulation class) Ask an expert, I want to make scrolling effect, how to use MSClass (Class Of Marquee Scroll universal uninterrupted scrolling JS encapsulation class) in php ) I saw that all the information provided on the Internet (http://www.popub.net/script/MSClass.html) is asp. Now I want to read the image data from the database, What should be done? ——Solution——————–Baidu Check Just fine

In PHP, if its modification is recorded in ACCESS

If you modify the record in ACCESS in PHPWhen PHP updates a single record in the ACCESS database, you don’t want to use the UPDATE statement. $mysql=”select * from myhelp where id=1″; if ($myconn->connect()) { $rs = new com(“adodb.recordset”); $rs->Open($mysql,$myconn->conn,1,3); $rs->movefirst; This sentence found this record to be updated, how to update it below, There is no such thing as $RS->EDIT and $RS->POST in PHP $rs->fields(‘mytt’)->value=$tt; $myconn->close(); How can I update the fields of this single record? The above code does not work. PHP Database Share to: ——Solution——————–$rs- >update() I see that you are using adodb, so how to use asp, you can use it

In php, how to pass two parameters through soap (under ms-security)

In php, how to pass two parameters through soap, (under ms-security) $xml = ‘                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ‘; $header = new SoapHeader(‘http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd’, ‘CallbackHandler’, new SoapVar($xml, XSD_ANYXML), TRUE);          $this->client = new SoapClient($wsdl);          $this->client->__setSoapHeaders(array($header)); $userInfo = turnObjectToArray($this->client->__call(‘checkUser’, array(‘username’ => array(‘username’ => ‘username’, ‘password’ => ‘password’)))); As soon as I run the above code, an error message appears SoapFault exception: [soap:Server] Fault occurred while processing. in Later, during the continuous adjustment, the other party looked at the log and it showed that the username was passed but the password was not passed When passing a parameter, the other party can receive it $info = turnObjectToArray($this->client->__call(‘getClasses’, array(‘gradeId’ => array(‘gradeId’ => $data[‘id’])))); How to pass two parameters? ? ? ——Solution——————–Pay attention to capitalization !

In PHP, a file calls another file class, and then the output is garbled. Solution

In PHP, a file calls a method of another file class, and then the output is garbled. Please solve it! tt.php file <?php class CTest { private $m_str; public function SetData($data) { $m_str=$data; } public function GetData() { return $m_str; } } ?> File test.php <?php echo “Begin test “; //Normal display require_once ‘./tt.php’; $p=new CTest(); $p->SetData(“Could you get this data?”); $str=$p->GetData(); echo $str; // Unable to display normally ?> —— Display test.php execution results in the browser Begin test 锘 Share to: More ——Solution——————– class CTest { Private $m_str; Public function SetData($data) {           $this->m_str=$data; } Public function GetData() {           return $this->m_str; } } ——Solution——————–Please check whether the encoding of $data is consistent with the page encoding. ——Solution——————–Set up the page encoding

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索