search

php pseudo-static

Nov 22, 2016 pm 04:10 PM
php

Should we choose pseudo static or true static
1. There is no difference between using true static and false static for SEO
2. Using true static may cause hard disk damage and affect the forum performance
3. Using pseudo static will take up a certain amount of space Amount of CPU occupancy, heavy use will cause CPU overload
 4. The most important point is that we need to be static for SEO
 So:
 1. Using the true static method can be directly eliminated, because no matter how it is generated, it will affect the hard disk It's all very hurtful.
 2. Since the effect of true and false static is the same, we can choose pseudo static.
 3. However, extensive use of pseudo-static will cause CPU overload.
 4. So as long as we don’t use it in large quantities, it’s fine.
 5. Since static is only for SEO, we only need pseudo-static for SEO, and there is no need for users to use it.
 6. So we only need to use pseudo-static in the Archiver specially provided for SEO crawling.
 7. Thank you all for patiently reading my article.
8. If you have any questions or different opinions, please feel free to comment on pseudo-static and true static. There is an essential difference between true static and pseudo-static. Processing a pure HTML for browsing users and a PHP that calls multiple data have significantly less CPU usage than the former. I remember someone once said that the hard disk is frequently read and written when downloading HTML. He said this as if reading the database does not require reading and writing to the disk. What's more, there are a lot of cached scattered PHP that are also placed on the hard disk. Doesn't these reads require disk operations? ridiculous.
 The purpose can be achieved by reading a single html + image Flash and other attachments. Why bother reading the database, reading the php cache file, re-integrating the data output, and adding image Flash and other attachments? The CMS homepage does not require a lot of interaction, and the forum version should not be used here. On the contrary, what should be considered more is: beauty! compatible! Intuitive information! performance! And stability!

I am transferring a php pseudo-static implementation of four methods:

1 2 //Pseudo-static method one
3
4 // localhost/php100/test.php?id|1@action|2
5 $Php2Html_FileUrl = $_SERVER["REQUEST_URI"];
6 echo $Php2Html_FileUrl."
";// /php100/test.php?id|1@action|2
7 $Php2Html_UrlString = str_replace("? ","",str_replace("/", "", strrchr(strrchr($Php2Html_FileUrl, "/"),"?")));
8 echo $Php2Html_UrlString."
";// id| 1@action|2
9 $Php2Html_UrlQueryStrList = explode("@", $Php2Html_UrlString);
10 print_r($Php2Html_UrlQueryStrList);// Array ( [0] => id|1 [1] => action|2 )
11 echo "
";
12 foreach($Php2Html_UrlQueryStrList as $Php2Html_UrlQueryStr)
13 {
14 $Php2Html_TmpArray = explode("|", $Php2Html_UrlQueryStr);
15 print_r( $Php2Html_TmpArray);//Array ( [0] => id [1] => 1 ) ; Array ( [0] => action [1] => 2 )
16 echo "
";
17 $_GET[$ Php2Html_TmpArray[0]] = $Php2Html_TmpArray[1];
18 }
19 //echo 'Fake static: $_GET variable
';
20 print_r($_GET); // Array ( [id| 1@action|2] => [id] => 1 [action] => 2 )
21 echo "
";
22 echo "


";
23 echo $_GET[ id]."
";// 1
24 echo $_GET[action];// 2
25 ?>
26

1 2 //Pseudo-static method two
3
4 // localhost/php100/test.php/1/2
5 $filename = basename($_SERVER['SCRIPT_NAME']);
6 echo $_SERVER['SCRIPT_NAME']."
";// /php100/test.php
7 echo $filename."
";// test.php
8
9 if(strtolower($filename)=='test.php'){
10 if(!empty ($_GET[id])){
11 $id=intval($_GET[id]);
12 echo $id."
";
13 $action=intval($_GET[action]);
14 echo $action."
";
15 }else{
16 $nav=$_SERVER['REQUEST_URI'];
17 echo "1:".$nav."
";/ / /php100/test.php/1/2
18 $script=$_SERVER['SCRIPT_NAME'];
19   echo "2:".$script."
";// /php100/test.php 
20    $nav=ereg_replace("^$script","",urldecode($nav)); 
21   echo $nav."
"; // /1/2 
22    $vars=explode("/",$nav); 
23   print_r($vars);// Array ( [0] => [1] => 1 [2] => 2 ) 
24    echo "
"; 
25   $id=intval($vars[1]); 
26   $action=intval($vars[2]); 
27  } 
28  echo $id.'&'.$action; 
29 } 
30  ?> 
31  

1 2 //伪静态方法三 


5 function mod_rewrite(){ 
6 global $_GET; 
7 $nav=$_SERVER["REQUEST_URI"]; 
8 echo $nav."
"; 
9 $script_name=$_SERVER["SCRIPT_NAME"]; 
10 echo $script_name."
"; 
11 $nav=substr(ereg_replace("^$script_name","",urldecode($nav)),1); 
12 echo $nav."
"; 
13 $nav=preg_replace("/^.ht(m){1}(l){0,1}$/","",$nav);//这句是去掉尾部的.html或.htm 
14 echo $nav."
"; 
15 $vars = explode("/",$nav); 
16 print_r($vars); 
17 echo "
"; 
18 for($i=0;$i19 $_GET["$vars[$i]"]=$vars[$i+1]; 
20 } 
21 return $_GET; 
22 } 
23 mod_rewrite(); 
24 $year=$_GET["year"];//结果为'2006' 
25 echo $year."
"; 
26 $action=$_GET["action"];//结果为'_add' 
27 echo $action; 
28 ?> 
29 

1 2 //伪静态方法四 

4 //利用server变量 取得PATH_INFO信息 该例中为 /1,100,8630.html   也就是执行脚本名后面的部分 
5 if(@$path_info =$_SERVER["PATH_INFO"]){ 
6 //正则匹配一下参数 
7 if(preg_match("//(d+),(d+),(d+).html/si",$path_info,$arr_path)){ 
8 $gid     =intval($arr_path[1]); //取得值 1 
9 $sid     =intval($arr_path[2]);   //取得值100 
10 $softid   =intval($arr_path[3]);   //取得值8630 
11 }else die("Path:Error!"); 
12 //相当于soft.php?gid=1&sid=100&softid=8630 
13 }else die('Path:Nothing!'); 
14 ?> 
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Optimize PHP Code: Reducing Memory Usage & Execution TimeOptimize PHP Code: Reducing Memory Usage & Execution TimeMay 10, 2025 am 12:04 AM

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools