cool hit counter If you want to learn php, why not check it out here_Intefrankly

If you want to learn php, why not check it out here


php language images

Basic commands

win+R to open command line, cmd into DOS window DOS commands to turn on and off Apache and Mysql Apache startup shutdown command

httpd -k stop  
httpd -k start  
httpd -k restart

Mysql startup shutdown command

net stop mysql
net stop mysql

Apache default home page

index.php index.html index.htm // priority from left to right The priority is defined inside the httpd.conf file

A brief introduction to the php language

php is not a strongly typed language, it is a weakly typed language (parsed language), it does not need to be declared in advance, it is judged by the program itself, unlike strongly typed languages, it does not need to be compiled and then used, apache can call php parser to parse php code directly, html is directly nested in php code, currently if in the php file

basic knowledge

Variable names in php are case sensitive, function names and class names are not, so simply variable and function names are all lowercase Three characters for one Chinese in utf-8 encoding Two characters for one Chinese when encoded in gbk

Variable Output

   echo $name;//output variable
   var_dump($name);// output the array and print the type and length
   print_r($name);// output the array, but not the type and length
  • 1.Define common variables $name = "Simon";
  • 2.Variable variables $str = "name"; $$str = " small red";// tantamount to$name = " small red";
  • 3.Variable references $a = $b It's the one that puts$b is assigned to the value of$a $a = &$b It's the one that puts$b Home address for$a
  • 4.exports When echo outputs a boolean type, true becomes 1 and false becomes null
  • 5.sources Connecting to database resources$conn = mysql_connect(" hostname (of a networked computer)"," user ID"," pin number"); File opening resources Directory Open Resources

basic function (math.)

  • 6.The isset function Determine if a variable exists, is undefined or is null
  • 7.The empty function Determining whether a variable is empty,0 "" "0" false array() null No definition these7 The case where all of them are empty
  • 8. Variable Type Test functions
 Integer is_int();
 Floating-point type is_float();
 Character type is_string();
 Boolean is_bool();
 Array is_array();
 object is_object();
 Resource is_resource();
 null type is_null();

Variable Type

Scalar type Integer Floating-point Character Boolean Composite types Arrays Objects Special type Resource null type

 is_scalar() tests if it is a scalar
 is_numeric tests if it is numeric integer floating point
 is_callable() tests if it is a function, and the language structure returns false
  • 9.language structure
 echo() is not a function, although it can be followed by parentheses, similar to a function
 print() is also a language construct, while printf is a function
 array() is also a language construct
 list() is also a language construct
  • 10.type conversion Only for scalar quantities Auto-conversion Similar to C reshaping -> string (computer science) 3 -> "3" $num = 123; echo $num."abc"; character type -> integers "3" ->3 $str = "123"; echo $str + 1; Other types -> Boolean type harmonyempty() The same happens when the function is empty inside $num = 0;// will convert to a bool type falsefalse
if($num){
 //If true then execute
} 
else{
}

Forced type conversions Same as in C (type name) variable For example(float)$num

  • 11.Deleting variables unset($name); The variable names are in parentheses
  • 12.The difference between single and double quotes in strings
    • Single quotes are faster to execute than double quotes, and double quotes have to be checked on output to see if the walk through is a variable
    • Variables cannot be parsed in single quotes, but can be parsed in double quotes
    • Use single quotes if there are no variables in the string, or double quotes if there are variables in the string

Constants in php

  • 13.Definition of constants Like variables, but once defined, they cannot be modified. It is better to capitalize constant names for easy differentiation, similar to macro definitions in C For example.
define("HOST","localhost"); 
define("USER","root");
define("PASS","123");
define("DBNAME","test");

Constants are used in the database configuration file and cannot be modified later Constants can't be put inside double quotes or inside brackets, they have to be used with . to connect constants

  • 14.Predefined constants
 PHP_OS System Platform
 PHP_VERSION The current version of php
 __LINE__ What line of code is this line on
 __FILE__ Absolute path to the file
 __FUNCTION__ Name of function
 M_PI Circumference
  • 15.Operators (no Chinese in the file name, otherwise there may be an error) The @ operator masks the error message of the function and is used when doing debugging Array Operators =>
    • Indexed arrays
$arr = array("use1","use2","use3");
echo $arr[1];
    • associative array
$arr = array("name"=>"user","age"=>"30");
echo "<pre>";
print_r($arr);
echo "</pre>";

Object operator -> Object use logical operator Switch function && If the preceding is true, before judging the latter, harmonyC Lingua Franca, interview session, But there's no real point.

  • 16.The date function
date("Y-m-d"); Year and month of the system,Y,m,d The order is interchangeable!
date("w"); System's days of the week
  • 17.Color change code for tables with spaced rows header header change encoding format utf-8, gbk
header("content-type:text/html;charset = utf-8");
<?php
    $days = 31;
    echo "<table width = '700px', border = '1px'>";
    for($i = 1, $k = 1; $i <= $days;){
         // Determine the color of a row by determining the number of rows as they are generated
        if($k % 2 == 1){
            echo "<tr bgcolor = 'grey'>";
        }
        else{
            echo "<tr style = 'background:blue'>";
        }
         //seven-day cycle
        for($j = 0; $j < 7; $j++){
            if($i > $days){
                echo "<td> </td>";
            }
            else{
                echo "<td>{$i}</td>";
            }
            $i++;
        }
        echo "</tr>";
        $k++;
    }
    echo "</table>";
?>
  • 18.Terminating script functions
 exit(); The () at the end can be left out
 die(); The () that follows can be left out and can have content in it
 for example:die(" Script termination");
  • 19.Functions of php to understand
    • php functions can be passed values, or they can be with default function arguments, just like C++
    • The output and return of functions, error-prone points, return value of the function more commonly used, and then want to output the results of the function in the output, rather than a call to the function will print the results of the function on the screen
    • Variable argument function, C language can also be implemented, php is its own function to achieve, func_num_args () can get the current number of arguments to the function, func_get_args () to get the specific value of the arguments passed in, stored as an array, and then use array_sum (func_get_args ()) to get the sum of the data passed in variable function, Assign the name of the function to a variable, Then you can use the function's functions with variables, for example:$a = "sum",sum is the name of a function,echo $a(1, 2); similarlyC++ The variable reference of
    • The scope of variables is similar to C. The global keyword can turn local variables inside the function into global variables, but it is better not to use it, it will interfere with the variables of the same name outside the function. If you want to change the value of variables outside the function through the function, you can use the reference method of function parameters, this is the same as the method of C++, the essence is to find the address of the variable first, and modify the value inside the address
    • A callback function, where the argument of the function is another function, or a kind of argument
    • Static variables are the same as the C keyword, static

The file contains

The difference between include() and require()

    1. include(), Inside the brackets is the name of another file, But also note the path to the file, Of course the same directory of The file contains, Don't worry about the path.
    1. require(), and include() are used in the same way, but if the included file is not found, the php script will be terminated and the following code will not be executed (whether it is correct or not), while it will still be executed in include
  • 20.The execution process of php Loading pages, syntax checking (loading functions), executing scripts
  • 21.php arrays An array is made up of multiple elements, each consisting of key-value, value with eight data types Indexed arrays harmony associative array The mixed use of, associative array The use of this does not affect the Indexed arrays subscript of For example.$arr = array("name" => 1, 2, 3, 100 => 4, 5, "age" =>6), Their subscripts are printed as"name", 0, 1, 100, 101,"age" The array takes the value printf_r($arr); array assignment.$arr['age'] = 30 , array assignment can also define arrays that$arr[] = 1; $arr[] = 2; They don't mean much.

Three ways to do array traversal

for Loop to do with numbers Indexed arrays travel throughout, but (not)foreach() You can iterate over all arrays,foreach($arr as $key => $val),as just from$arr take a value from$val, And then print the values of the array inside the loop, associative array Indexes are called key-value pairs,list harmonyeach Traversing arrays, It feels like trouble.,while(list($key,$val) = each($arr)){echo "<h1>{$key}:{$val}</h1>"; Multidimensional arrays, arrays inside arrays, e.g. two-dimensional arrays:$arr = array(1, 2, array(4,5)); A data table is actually a two-dimensional array, and each row of records in it is a one-dimensional array

22.Superglobal arrays

 $_SERVER View server information, print server-related information with print_r, do not use echo
 $_GET Get the data submitted by get, communication between two pages, form passing (get way, post way)
 a tag to pass a value (get to pass a value), get to pass a value can be seen on the address, unsafe
 a tag is recommended to use get to submit data, and the form is recommended to use post to pass the value at the way.
 And $_POST gets the data passed by the form post, $_REQUEST gets the data passed by the a tag or form get or post
 $_REQUEST is equivalent to $_GET and $_POST
 Cookies and sessions cannot be preceded by output
 $_COOKIE The same variable is fetched on multiple pages
 $_SESSION The same variable is fetched on multiple pages
$_FILES gets the files in the form and generates an array
$GLOBALS  It contains global variables within the page, Changing the value of an external variable inside a function, You can use$GLOBALS[$name] = "...";
  • 23.array function Key-value manipulation functions for arrays
     array_keys(); Get the key in the array, the parameter is the array name
     array_vals(); Get the value in the array, the parameter is the array name
     array_key_exists(); Check if a key is in an array  
    in_array(); Check if a value is in an array, The parameters inside are" happen to" and array names
     array_flip(); Keys and values are swapped and the parameters are array names
array_reverse(); The values in the array are reversed, that is, the function returns an array in the reverse order of the original array

Elements and uniqueness of statistical arrays

     count(); Counting the number of elements in an array
     array_count_values(); Counts the number of identical values in an array and returns a new array
     array_unique(); Remove duplicate values from an array

Functions that use callback functions to handle arrays (filtering)

     array_filter(); Array value filtering, filtering out the values that match the conditions, the parameters are the array name and the conditions
     array_map(); Acts the callback function on the elements of the given array, with the function and the array as arguments, returning a new array

Sorting functions for arrays

     sort(); Ascending order, no key retained
     rsort(); Descending order, no key retained
     asort(); Retain key in ascending order
     arsort(); Retain key in descending order
     ksort(); Sort the key in ascending order according to the value, and swap the key and value after sorting
     krsort(); Sort the keys in descending order according to their values, and swap the keys and values after sorting
     natsort(); Use the natural sorting algorithm to sort ascending, if you want to sort descending, you can then use the array_reverse() function to invert
     natcasesort(); Ignore case ascending order
     array_multisort(); Sorting multiple arrays

Splitting, merging, decomposing and combining functions

explode(); split function (math.), for example:explode("-",$arr);
 join();//implode(); They are all merge functions 
array_slice();

The arguments are the variable name, starting scalar, and ending scalar, e.g., ``array($arr, 0, 3); ```Positive numbers are intercepted from left to right and negative numbers are intercepted from right to left into an array, while the original array remains unchanged

array_splice();

The usage is similar to array_slice, except that it not only generates a new array, but also turns the original array into the remainder of the intercepted part, and more powerfully, it can add elements to the original array where it was cut, for examplearray_splice($arr, 0, 3, array("ff", "gg", "hh")); The added element is placed in the original array where it was cropped

 array_merge($a, $b); Merge two arrays into one
 array_combine($a, $b); and concatenate arrays so that the preceding array becomes the subscript of the following array 
 array_intersect(); Takes the intersection of two arrays
 array_diff(); The front is used as a reference, and the elements in the array behind that are not the same as the front are taken to find the difference set

Arrays and data structures

 array_pop() pops the last element of the array, changes the original array, and returns a new array, not unlike unset()
 array_push(); Returns the number of elements in the new array, changing the original array
array_shift(); Pops a value at the top of the array, returns the moved value, and the original array subscripts are rearranged
 array_unshift(); Insert a value in front of the array and return the number of arrays

Other useful array handling functions

 array_rand(); Take a random key
 shuffle(); Disrupting an array
 array_sum; Find the sum of all values of the array
 range(); Get a range array with two parameters that can do captcha
  • 24.string (computer science)
    • echo harmonyprint differences,echo Multiple strings can be concatenated, for example:echo "aaa","bbb","cccc"; but (not)print cannot
    • printf can format the output, as in C, with the format specifier %s, $d
    • sprintf can also be formatted, but instead of outputting directly, it returns a string Use some. to concatenate the string

String functions

     function to remove spaces and string fill (to solve the problem of not being able to log in due to extra spaces typed in the username)
     ltrim(); Removes spaces from the left side of the string
     rtrim(); Removes spaces from the right side of the string
     trim(); Removes spaces from the left and right sides of the string
     str_pad(); to fill the string to the specified length, using another string to fill the string to the specified length.
 for exampleecho str_pad($str, "-", (STR_PAD_LEFT)); The last parameter can be written or unwritten
    str_repeat();  How many times to repeat a string, for exampleecho str_repeat("_",3), exports ___
     strlen(); Get the length of the string

String Case Conversion Functions

    strtoupper();
    strtolower();
     ucfirst(); Capitalize the first letter of the string
     ucwords(); Capitalize the first letter of each word in the string

String functions associated with html (seen in conjunction with the database)

     nl2br(); classifier for objects with a handle
 convert tobr label, for exampleecho nl2br("aaaa
bbbccc"); Use line breaks when interacting with other languages
    htmlspecialchars(); conversion to an entity, forward (mail)“、< > &”, For malicious input, as-is output
     strip_tags(); Remove the html tags, or you can keep some of them, and add the tags you want to keep after the parameters, remembering to put them in double quotes
    addslashes(); transferred meaning' "  , Precede them with, harmonyC The same escaped characters for languages, defaultphp turn on
     stripslashes(); Remove the adslashes added by default

String comparison functions (ASCII)

 1.String comparison by byte
     strcmp($str1, $str2); Compare each byte of a string
     strcasecmp(); Compare each byte of a string ignoring case
 2.Comparison of strings when sorting by natural
     strnatcmp(); Compare numbers in a string by natural order
     strnatcasecmp(); Ignore comparing numbers in strings by natural order

Splitting and splicing strings (same as in the previous array section)

 1.Split explode(); Splitting strings into arrays
 2.Spliceimplode() (join()); Splicing strings into strings

String interception

 substr(); The parameters are the variable name, the starting position coordinates (starting from 0), and the ending position coordinates.
  Attention needs to be paid to encoding issues, and character encoding could be harmonized that
 for example:( This one supports multi-byte)echo mb_substr($str, 0, 6,"utf-8"),
 Whether the characters are in Chinese or English, the first 6 are intercepted

Query String

     1.strstr(); Finds the first occurrence of the specified character in a string, returning a string, but not precise enough
     2.strrchr(); Find the last occurrence of the specified character in the string
     3.strpos(); Find the position of the first occurrence of the specified character in the string
    4.strrpos($str, 'w');w (located) at$str The position of the last occurrence in

String Replacement

 1.str_replace(); The arguments are two strings and a string name, the later replaces the earlier, but want to replace multiple different strings
 Multiple substitutions can be achieved by putting them in an array and then using the array as the first argument, the
 And it is also possible to implement multiple substitution of multiple, that is, the second parameter is also turned into an array, and the two arrays are replaced correspondingly

String splitting common functions

1.pathinfo($str);
 2.parse_url($str); Specifically for url address splitting
3.parse_str($str['query'], $arr); Splitting up to be more specific
4.preg_split('/ /',$srr['']); regular splitting

Other String Functions

     strrev(); String flipping
     strlen(); String length
     number_format(); Formatting a numeric string by adding a (,) for every three characters
     There is also the option to retain a few decimal places, which can be formatted to your own requirements
     md5(); The md5 encrypted string, encrypted as a 32-bit string
     str_shuffle(); Random output string, same as shuffle inside an array
  • 25.Three gates are recommended before data is inserted into the database
     1.[b]aaaaaaa[/b] UBB code, using strip_tags to filter some of the html tags
    2.addslashes()
    ' "   before adding, Preventing damage to the database
    3.htmlspecialchars()
     will' " < > &  Conversion to entity, Preventing damage to the database
  • 26.regular expression Regular expression is a syntax rule used to describe the character arrangement and matching pattern, it is mainly used for string pattern segmentation, matching, finding and replacement operations, in PHP regular expression is generally a procedural description of a text pattern composed of regular characters and some special characters jointly, this time using perl compatible regular expressions
    • 1.atomic ... (dot) represents any character, but cannot match a line break w for any letter, number, underscore W Any one character except letters, numbers, underscores d for any one number D for any non-number s Match blank characters, spaces, tab S Except for blank characters, spaces, tab . Escape character, representing a common character .(dot) [abc] Any of the characters in it [^abc] It contains any one but abc unit ()
    • 2.genus sign *(asterisks) 0, one, many Modify any number of preceding atoms + (plus) one, more than one, at least one What? (question mark) 0, multiple, optional, generally used in combination with unit | perhaps ^ What does it start with? $ What does it end with? word edge B Non-word edges {2} 2 atoms {2,} 2 preceding atoms {2,5} 2-5 preceding atoms
    • 3.Pattern modifier /regular-expressions/U i, m, s, U, e i Ignore case m Considered multi-line s Considered as a line U Greedy mode, maximizing meticulous matching patterns e used in the replacement can be processed backwards with the function
    • 4.examples $str = "LINUX and php are lamp or linux is good"; $ptn = '/linux/i';// Matches out the string oflinux preg_match_all($ptn, $str, $arr); echo "<pre>"; print_r($arr);// can match out LINUX and linux echo "</pre>";

    eval makes string expressions executable

  • 27.Regular expression function
     String matching and finding
     1.preg_match(); regular expression matching
     2.preg_match_all(); regular expression full match
     3.preg_grep(); You can do a search
     String Replacement
     4.preg_replace(); Regular expression substitution
     String splitting
     5.preg_split();  Regular expression splitting
  • 28.mathematical function
     Note: There are two types of parameters, 1. multiple numbers, 2. an array of multiple numbers
     1.max(10,5,8); take the maximum value
     2.min(); take the minimum value
     3.mt_rand(); Randomly go to a value where the argument is a range
     4.ceil(); The last integer from that number, not rounded
     5.floor(); The next integer from that number
     6.pi(); Taking the circumference function
     7.round(); rounding function
  • 29.Date functions
    • 1.time(); The current timestamp, i.e. the origin time of the birth of C and unix at 0:0:0 on January 1, 1970, will be a time overflow on 32-bit machines in 2038
    • 2.date("Y-m-d H:i:s"); The parameters are y (2016) y (16) m (09 months) n (September without zero) d (05 days) j (5 days without zero) H:24-hour h:12-hour i:00-59 minutes s:00-59 seconds w (0-6 Sunday-Saturday) t (31) how many days in a month L whether it is a leap year A:AM or PM a:am or pm Year, month, day, hour, minute, second, small y for the last two digits of the year, with time zone rules
    • 3.strtotime(); Convert a string date to a timestamp, either future time or past time, such as 2016/9/11 or 2015-3-4
    • 4.microtime(); 1 second = 1000 milliseconds = 1,000,000 microseconds To do the math for the two times, you need to pass a parameter of 1 inside microtime
    • 5.sleep(1) delayed for one second

Functions related to time zones

1.date_default_timezone_set(" Time zone name abbreviations"); The abbreviation for China isPRC
 2.date_default_timezone_get(); the default time zone, which is related to the PHP configuration file.
Inside php.ini you can change the default time zone so that you don't have to set the default time
3.date_timezone_set();
4.date_timezone_get();
  • 30.Error handling in php
    • 1.Turning off and on error reporting display_errors = On display_errors = Off (not recommended)
    • 2.Error Level E_ALL All the following errors E_NOTICE prompt error, script does not terminate E_WARNING warning error, script does not terminate E_ERROR Serious error, script terminated E_PARSE Syntax error, script terminated
    • 3.Controlling the level of error reporting error_reporting = E_ALL E_ALL & ~E_NOTICE Report all errors, But in addition to prompting an error
    • 4.Reported error place display_errors = Off//whether to output errors from the browser log_errors = On// Whether to output errors to a custom log file Modify the path to the file error_log = e:phplogsphp.log
  • 31.GD library drawing steps 1.Prepare the canvas 2.Preparing the paint 3.paint 4.exports pictures 5.Save image 6.Close the canvas
  • 32.php image processing functions
    • 1.Applicable scenarios Captcha, Zoom, Crop, Watermark
    • 2.Image format jpeg (jpg) is one of the most popular image types, and it uses a lossy compression format png is the most common type of image used on the web, and it uses a lossless compression format when gif is the most common image type used on websites, it can support dynamic images, it uses lossless compression format
    • 3.Five steps to creating an image
      • 1.Prepare canvas resources (to be released when resources are created and used up) $im = imagecreatetruecolor(); The parameter is the size of the canvas
      • 2.Preparing the paint $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); Parameters are canvas and color (decimal and hexadecimal)
      • 3.Draw an image or text on the canvas (the default fill of the canvas is black) imagesetpixel(); Set the pixel points, plus the for loop to do the captcha jammer iamgeline(); Draw a line with parameters x, y of the coordinates starting point and x, y of the end point imagerectangle(); Draw a rectangle with parameters x, y of the coordinates starting point and x, y of the end point imagefilledrectangle(); Draw a rectangle and fill it imagepolygon(); Draws a polygon with parameters array, number, and color imagefilledpolygon(); Draw a polygon and fill it imagearc(); Draw a circular arc imagestring(); Draw a string horizontally imagestringup(); Draw a string vertically imagechar(); Draw a character horizontally imagecharup(); Draw a character vertically imagettftext(); Draw a string to an image using the truetype character imagefill($im, 0, 0, $white); Fill the canvas, from what position and in what color imagellipse($im, 0, 0, 100,100); Draws circles and ellipses, the parameters are canvas, drawing position, width and height of ellipses
    • 4.exports Or save the final image header("content-type:image/png"); imagepng($im); Output in png format, if you want to save the image, you need to add a parameter with the name of the image in it, note the format
    • 5.Release canvas resources imagedestroy($im);
  • 33.php jump design 1.page jump php way of jumping (no output in front of header, this is not recommended) header("location:index.php"); js way of jumping (preference for this method) echo "<script>location = ' address'</script>"; echo "<script>location = 'index.php'</script>";
  • 34.Image related functions
    • 1.Get the width and height of the image getimagesize(); The parameters are the file name imagesx(); Get the width of the image imagesy(); Get the height of the image
    • 2.Canvas resources already exist for formation imagecreatefromjpeg(); Print out images
    • 3.Image scaling functions (isometric problems) imagecopyresampled();
    • 4.Image cropping functions imagecopyresampled();
    • 5.Image watermark function imagecopy();
  • 35.Document processing
    • 1.File test functions filetype(); File directory, the argument is the file name, return dir (folder) or file (file) is_dir(); Determines if it is a directory, returning a boolean value is_file(); Determines if it is a file, returning a boolean value file_exists(); Whether the file or directory exists, returns a boolean value filesize(); File size or directory size (4kb)
    • 2.File manipulation functions fopen($filename,"w"); The parameters are the file name and the read or write method, harmonyC Same language file manipulation File open mode r Open read-only, pointing the file pointer to the file header r+ Open in read-write mode, point the file pointer to the file header, erase and write later w Write to open, point the file pointer to the file header and truncate the file size to zero, or try to create it first if it does not exist w+ open read/write, point the file pointer to the file header and truncate the file size to zero, and empty the file of its original contents, or try to create a new file first if it does not exist a Write to file open, point file pointer to end of file, try to create file if it does not exist a+ Open in read-write mode, pointing the file pointer to the end of the file, or try to create the file if it does not exist fclose(); Close the file unlink(); File deletion copy(); File copy change, the parameters are the file and the new file path, and you can change the file name, cut is to copy first and then delete the original file rename(); Rename the file name with the parameters file and new file name fread(); File read, parameters are file resources and read length file(); No resources required, return the file as an array readfile(); No resources required file_get_contents(); Reading the contents of a file does not require resources and can be printed later Write to file contents file_put_contents(); Writing the contents of a file does not require resources Moving the file pointer ftell(); Tell current location fseek(); Pointer to the specified position rewind(); Pointer returns the beginning of the file feof(); Determine if the file pointer has reached the end of file position
    • 3.Directory Operations mkdir(); Creating directories (folders) rmdir(); Delete a directory, not if it contains content
    • 4.Functions related to paths basename(); Takes the last file name in the path dirname(); Takes the path in the path other than the last filename realpath(); The parameters inside are. Or... ...for the current directory, ... represents the previous directory, each folder has two hidden files . and ..., you can convert relative addresses to absolute addresses FILE Current file address superglobal variable DIRECTORY_SEPARATOR; Directory separator, windows is /, linux is / PATH_SEPARATOR; Command separator, windows is; linux is pathinfo(); The path information of the file and store it inside an array parse_url(); The path information of the browser address and store it inside an array parse_str();

    5.Catalogue size opendir(); readdir(); Open Read Folder closedir(); Delete the directory resource, then rmdir() in the deleted directory itself;

  • 36.File Upload
    • 1.Client upload settings post method enctype = 'multipart/form-data' max_file_size maximum file size, which can be changed in php.ini
    • 2.Handling uploads on the server side via php upload_max_filesize input type = file Maximum value of the file in the upload box post_max_size The total size of the form form, definitely the size of the file type upload box $_FILE['myfile']['error'] 0 means no error occurred 1 means that the size of the uploaded file exceeds the agreed value, which is the value of upload, but cannot exceed the value of post 2 Indicates that the upload file size exceeds the form limit, is in the form<input type = "hidden" name = "MAX_FILE_SIZE" value = "10000"> to set 3 indicates that the file was only partially uploaded 4 means that no files were uploaded
    • 3.Multi-file upload Using a for loop
    • 4.File download (know the file type before downloading the file) 1.header("content-type:image/png"); 2.header("content-disposition:attachment;filename=a.txt); 3.header("content-length:30KB"); 4.readfile('a.txt');
  • 37.mysql database
    • The data table consists of three parts 1.Table Structure Column Information 2.Table Fields (Data) Row Information 3.Table record (index) Add the rows in the column to the index (in general a table must have all the data in the id column added to the primary key index)
    • mysql basic commands 1.net stop mysql Shut down mysql 2.net start mysql Start mysql 3.mysql -uroot -p123456 4.show databases; 5.use test switch the test database 6.show tables; View all tables 7.select * from t1; View all data in table t1 8.desc t1; View the t1 table column structure 9.exit Quit the mysql client 10.desc user View table records
    • Database operations
      • 1.Create database The sql command is not case sensitive, each database will be one more folder, the database name is not case sensitive under window, the opposite under linux
      • 2.View Database show databases;
      • 3.Delete database drop database t62;
      • 4.Switching the database use test;
    • table operation 1.view table show tables; 2.table creation mysql> create table user( -> id int, -> name varchar(30), -> pass varchar(30) -> ); 3.revision form rename table t1 to user; 4.delete table 5.View Table Fields desc user; 6.View Table Data select * from t1;// the table from which select id from t1; 7.View table structure desc user;
  • 38.Database design
    • 1.numerical value // display and size, this display is meaningless unless you must make up the 0 on the left, this column has to have the zerofill attribute and your column becomes unsigned int //int(3) is length independent, not enough 3 bits to fill in the front with 0, default is invisible float
    • 2.String (display and number) // name: char varchar title: varchar(30) content: text type char(n) is faster, n length max 255, takes up n bytes varchar(n) save space, store how many bytes accounted for how many bytes, store l + 1 text 65535 bytes longtext longtext 4.2 billion bytes
    • 3.Date and time data time datatime year timestamp // replace the date type with a shaped timestamp, save the time() timestamp to the int column in mysql in php, suggesting that the date be stored as an integer
    • 4.Data Field Properties unsigned unsigned, no negative numbers zerofill zero-fill, int(3), not enough bits to make up the zero auto_increment Self-incrementing, id use null Default property, this column is allowed to be null not null is used in conjunction with the following to change the attribute default
  • 39.View basic server-side information with s view Four character sets. Server character set Server characterset: utf8 Database character sets Db characterset:utf8 client-side character set Client characterset: utf8 Connection character set of the client Conn. characterset: utf8 show create database t1; View information about database t1 when it was created View database character set show create database test; View table character set show create table user;
  • 40.Database additions, deletions and checks // In mysql there is no ==, only =, which contains both assignment and comparison Add insert insert into t1(usename) valuse('f'); Change update update t1 set username='g' where id=6; Change multiple values at once, separated by commas update t1 set username='gg',id=66 where id=6; delete // must add where condition, if not delete all, this time should use delete from t1 where id=3; delete from t1 where id>=3 and id<=5; delete from t1 where id between 3 and 5; delete from t1 where id=1 or id=3 or id=5; delete from t1 where id in(1,3,5);

Recommended>>
1、New programmers learning to program are at least 50 useless what percent are you up to now
2、Google replaces database components with ML model or revolutionizes data systems development
3、Into the car intelligent hardware reliability automation test environment the most professional IoT test laboratory to explore
4、The Youth Law Club is going to talk about big data in politics and law come and pick it up
5、Bitcoins Shocking Secret Revealed 4 Percent of Addresses Hold 97 Percent of Bitcoins

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号