Yesterday when I used curl to write an api interface, I found that the Call to undefined function curl_init () error was prompted when running the curl function. From the error, the curl_init () function is not defined, later I learned that this function must open a file in php. The specific method is as follows.
I wrote the program code like this.
The Code is as follows:
Copy code
?? Php// Initialize a cURL object$ Curl = curl_init ();// Set the URL you want to captureCu
This article introduces how file_get_contents cannot obtain a URL with a port. For more information, see.
First, let's take a look at the file_get_contents () function. The official introduction says it reads the entire file into a string.
Example
Echo file_get_contents ("test.txt ");?>
Output:
This is a test file with test text.
This function can also be used to obtain the content on the remote server.
File_get_contents ('HTTP: // www. bKjia. c0m
server errors is not ruled out.
The second is that the function is very important. The curl_getinfo function will obtain the relevant information of the current request:
The Code is as follows:
Copy code
Array([Url] => http://www.bKjia. c0m/[Content_type] => text/html; charset = UTF-8[Http_code] = gt; 200[Header_size] = gt; 321[Request_size] => 53[Filetime] =>-1[Ssl_verify_result] => 0[Redirect_count] => 0[Total_time] = gt;
This php ajax application instance uses ajax + php to call the urban second-level linkage menu, so that we can update the menu in real time based on the database content.
The ajax application example of this php tutorial is an ajax + php call of the second-level urban linkage menu, so that we can update the menu in real time according to the database tutorial content.
Www. bKjia. c0m. php code
$ City_arr = array ("Ah" => "Hefei ","Fj
= "rooms /";// Encoding method$ Charset = "UTF-8 ";// Maximum number of content displayed on the client (not too large recommended)$ Maxdisplay = 300;
// Language$ Lang = array (// Chat room description"Description" => "welcome to the mini ajax chat room. The latest version is 1.2. Download // Chat room title"Title" => "mini ajax chatroom by longbill ",// First welcome to the chat room"Firstone" => "// Display the information when the content is forbidden"Ban" => "I am a pig! ",// Keyword"Keyw
Remote File Download Code: here we provide you with a remote file download code. We can use php to download remote files to a specified local directory, the following is a code class for downloading remote server files.
Remote File Download CodeHere we provide you with a remote file download code. We can use the php tutorial to download remote files to a specified local directory. Below is a code class for downloading remote server files.
Class download{Var $ url; // remote file address
Var $
How does the dedecms Q A system cancel credits and user login verification?/*Now I want to use dedecms for a q A function. This function does not require users to log on and ask questions. Because credits are required during the problem, I have canceled both the credits and credits.FindOpen the post. php tutorial file and find
If (! Isset ($ action) $ action = '';
If (empty ($ uid) $ action! = 'Rate ')
{
Showmsgs ('no _ login', '../member/login. php? Gourl = ../ask /');
Exit;
}
Php Date Format legality Regular Expression verification code this php Regular Expression date tutorial provides three methods to verify whether the date entered by the user is in the correct date format, one is to use checkdate for verification.
Php tutorial Date Format validity Regular Expression Verification Code
In this php regular date tutorial, three types of date formats are provided to verify whether the date entered by the user is in correct format. The two types are regular date verifi
Void var_dump (mixed expression [, mixed expression [,...])
This function displays the structure information about one or more expressions, including the expression type and value. The array recursively expands the value and displays its structure through indentation.
*/Function a_test ($ str) // User-Defined function{Echo "nhi: $ str"; // output parametersVar_dump (debug_backtrace (); // output backtrace}A_test ('friend'); // call a User-Defined Function
// Let's look at a var_dump to traver
normal to log on to Firefox and encountered problems when it was launched. The user is always logged on. So I checked the differences between cookie records in IE and Firefox. After testing, I suddenly realized.
If the fourth parameter (valid path parameter) of setcookie () is not specified, the current directory is used as the valid path by default, and the path I tested is: http: // 127.0.0.1/php/rss2fla/data/log. php. Therefore, the cookie paths set during login and exit are different.
IE is
the code for PHP to determine whether the alexa tool is installed in your browser:
The Code is as follows:
Copy code
If (! Preg_match ("# Toolbar # I", $ _ SERVER ['HTTP _ USER_AGENT ']) {showmessage (L ('alexa _ failure'), 'https: // www. bKjia. c0m', 8000 );}
(Because the User-Agent characters in firefox and ie are different, Alexa Toolbar in firefox and My Toolbar in ie. Therefore, we only need to determine whether th
Function removeBOM ($ str = ''){If (substr ($ str, 0,3) = pack ("CCC", 0xef, 0xbb, 0xbf )){$ Str = substr ($ str, 3 );}Return $ str;}?>
Therefore, the above BOM = pack ("CCC", 0xef, 0xbb, 0xbf), so the method for removing BOM can use the above removeBOM function or one of the following:
■ Str_replace ("replace", '', $ bom_content );■ Preg_replace ("/^ replace/", '', $ bom_content );Also see to judge whether this string is a function of the UTF-8:
The Code is as
your database. Take UTF-8 as an example,Open the excel file, save it, and select ". CSV" as the file.Then open the. csv file with the compiler and save it as a UTF-8 csv file.Then, you can use php's getcsv to open the php file (this ensures that some of your fields are included, resulting in parsing errors), and then import the parsed results to the database.
If it is in csv format, I do not need to be so troublesome.
The Code is as follows:
Copy code
// Connect to the d
To export the content in the mysql database to excel, you only need to use the header to output the csv format document, you can simply export the excel file in mysql. Let's take a look at the example below.
The core code is here.
The Code is as follows:
Copy code
Header ("Content-Type: application/vnd. ms-excel; charsets = UTF-8 ");Header ("Pragma: public ");Header ("Expires: 0 ");Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ");Header ("Content-
Curl is a FILE Transfer tool using URL syntax. It supports FTP, FTPS, http htpps scp sftp tftp telnet dict file and LDAP. Curl supports SSL certificates, http post, http put, and FTP uploads, kerberos, HTT-based upload, proxy, cookie, user + password proof, file transfer recovery, http Proxy channel and a large number of other useful techniques.
After php is installed, the curl function extension is not enabled by default. You can enable this function extension in the following steps.
Install cu
Php has a trime function for removing spaces. It can remove two spaces or directly use the ltrim function. The result of the rtrim function is the same as that of the trim function. If you want to delete all spaces, you only need to replace str_replace.
I usually think about spaces. I usually use trim. Today, I found that spaces in the middle cannot be removed. however, we can only find out the description. trim can only go to two ends, for example, $ abc = a B c;. trim can only remove spaces be
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.