php append to file
I like php’s file_put_contents function, which can write a string to a file with single line of code: file_put_contents(“file.txt”,”content”); Few languages have such powerful function. In C language, you need […]
I like php’s file_put_contents function, which can write a string to a file with single line of code: file_put_contents(“file.txt”,”content”); Few languages have such powerful function. In C language, you need […]
How to bind to variable number of variables in mysqli_stmt_bind_param() in one statement? mysqli_stmt_bind_param() itself can accept variable parameters. The prototype of mysqli_stmt_bind_param is: mysqli_stmt_bind_param ( mysqli_stmt $stmt , string […]
If you ever upgrade php5 to php7 for your server/vps/shared hosting, you probably encounter the following errors: Fatal error: Uncaught Error: Call to undefined function mysql_connect() Fatal error: Uncaught Error: […]
I have a project in which I need to convert a byte into an integer: <?php $a=md5(“hello”,true); echo $a[15]*1.0/255.0; The second parameter of md5 is set to true in order […]
I often got confused about JSON and JSON string. JSON is the code you write in your javascript script to represent an object, so the code is called JavaScript Object […]
If you use php curl to scrape web page, the retrieved content may be in compressed format,i.e., the Content-Encoding http response header may have the value “gzip”. How to uncompress […]
We know that we can customize http headers for php curl using CURLOPT_HTTPHEADER. But if we do not add additional headers, what http headers does curl send by default? In […]
I encountered a strange problem of php curl. I use curl to fetch a remote web page as follows: $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, “https://myprogrammingnotes.com”); curl_setopt($curl, CURLOPT_HEADER,1); curl_setopt($curl, CURLOPT_FRESH_CONNECT,1); curl_setopt($curl, […]
php curl is often used to fetch remote content. Sure you can use file_get_content to fetch remote web pages. But curl has more options to choose. We know that http […]
To debug .php web pages, you want to print something on the browser’s windows when opening the web pages. You can use the php echo or print function to display […]