Php code used to obtain the absolute path of the current file
$ Basedir = dirname (_ FILE __);
Echo $ basedir;
// An absolute path of the file will be printed on the page!
?>
You can use
Php forcibly downloads the code of a specified type of file
// Download prompt
// Site http://bbs.it-home.org
Function downloadFile ($ file ){
/* Coded by Alessio Delmonti */
$ File_name = $ file;
The stored code is directly prompted when the phpheader function file is downloaded.
$ Filename = 'path + actual filename ';
// File type
Header ('content-type: application/pdf ');
// Download the
Php provides download after reading the file and changing the file name
$ Filename = dirname (_ FILE _). '/oldfilename.exe ';
$ Out_filename = 'newfilename.exe ';
If ()){
Echo 'not Found '. $
In php, file_get_content simulates post data.
If ($ _ POST ['A'] & $ _ POST ['B']) {
Echo 'post data success! ';
Exit ();
}
?>
File 2: The main test file of indexx. php.
Learning Super global variables in php
Since PHP 4.2.0, the default value of register_globals is off. as a result, many variables can be used directly in the past, for example, $ PHP_SELF or the set SESSION variable cannot be accessed in
Example of global php global variable
$ A = 1;
$ B = 2;
Function Sum ()
{
Global $ a, $ B; // declare it as a global variable
$ B = $ a + $ B;
}
Sum ();
Echo $
Php code that verifies the validity and correctness of the email address entered by the user
Function validate_email ($ email ){
$ Exp = "^ [a-z '0-9] + ([. _-] [a-z '0-9] +) * @ ([a-z0-9] + ([. _-] [a-z0-
Access modifiers in php oop
/*
The following two methods declare that the access permission works the same
*/
Function say (){};
Publilc function say (){};
When a class member is
Php parses XML document attributes and edits the code
// Read xml
$ Dom = new DOMDocument ('1. 0 ');
$ Dom-> load ('data. XML ');
$ Em = $ dom-> getElementsByTagName ('videoos '); // outermost node
Php calls WebService to pass the time parameter
When WEBSERVICE is connected with other systems, it is found that PHP cannot identify time parameters in. NET. Analysis: WEBSERVICE code calling in PHP is implemented by manually compiling
Php functions for generating random user names and passwords
Description: generate a random user name and password. you can use the mt_rand or rand function in php. now the rand function is used more in the verification code, most of
Multi-Platform Mobile Web page pc remote video surveillance system source code sale transfer
This is a complete video monitoring system, including the WEB management background, data forwarding server, desktop monitoring client, mobile
How does a php website prevent SQL injection? [Top]
Website operation security must be considered by every Webmaster. as you know, most websites attacked by hackers use SQL injection, which is what we often say?The most primitive static
Common php design modes: Factory mode and Singleton mode
/**
Example of Factory mode
@ Link http://bbs.it-home.org
*/
Abstract class Operation {
Abstract public function getValue ($ num1, $
Usage of fgetcsv and compatibility issues in windows and linux
$ File = fopen ("contacts.csv", "r ");
Print_r (fgetcsv ($ file ));
Fclose ($ file );
?>
CSV file: George, John, Thomas, USA James,
A php code that accurately counts the number of online users
Using filename='online.txt '; // data file
$ Cookiename = 'vgotcn _ onlinecount'; // cookie name
$ Onlinetime = 600; // online validity
The problem of data packet loss transmitted by php big form using the post method
In the production environment, a huge form, including three images, hundreds of input boxes and nearly one thousand checkboxes, is intercepted when The
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service