"PHP Object-oriented
-
-
-
-
- If the current file has a namespace (namespace) when the PDO class is instantiated, the output will cause an error if the PDO class does not exist in the directory, so a backslash must be added before the PDO: \pdo
- instantiating a class can also be stored without variables, such as: New PDO ()
- preg_match ($pattern, $string); Returns the number of matches, parameter one is the regular expression, the second is the match content, this function matches only once, matches all please with Preg_match_all
- preg_ Replace ('/\{\$ ([\w]+) \}/', ' B ', ' {$dd}f imitation {$dd}4s65f '); Replace the regular match to the content and return, parameter one is the expression, the second is the replacement content, the third is the original text
- json_encode (); function Chinese garbled (u265/similar case ) and part of the symbol are converted by the workaround:
foreach ($data as $key = + $value) {$data [$key] = UrlEncode ($value);}
- UrlEncode for each value, return to UrlDecode (Json_encode ())!
- Namespace (namespace) used: A file app\ctrl\model.php, whose namespace should be namespace App\ctrl;
- Spec: namespace per-level initial capitalization, class name capitalization, constant all caps
- "Namespace and use keyword
- Start a namespace for the class: namespace plugin;
- Access this class with use: Using Plugin\nos;
- Note: This class must be introduced (include) when using use to access the class
- It is recommended to use Spl_autoload_register () to automatically load non-existent classes for you
"PHP Template
1. Why should I use a template?
- To separate PHP and HTML code, make maintainability even higher!
2. Why should I cache a template?
- To increase loading speed, improve performance and database endurance!
3. Why do I need to compile the template into a php file?
- The template uses some custom syntax, such as {$name}, in order to make it normal to display, you need to convert it to <?php echo $name output, the converted file compiled into a file, the next call directly!
4. How do I cache a template?
- Put the introduced compilation file as buffer Ob_start () and then use Ob_get_contents () to save the copied content to the cache file with File_put_contents ()
PHP Learning Summary (i)