PHP code optimization problems

Source: Internet
Author: User
PHP code optimization question a. php & lt ;? Php $ title = 'October 13 '; $ classid = '1'; $ a = 'a'; $ B =' B '; $ c = 'C '; $ d = 'd ';? & Gt; B. php & lt ;? Phpif (file_exists ('A. php') php code optimization
A. php
$ Title = 'October 22, March 5 ';
$ Classid = '1 ';
$ A = 'a ';
$ B = 'B ';
$ C = 'C ';
$ D = 'd ';
?>

B. php
If (file_exists ('A. php ')){
Include ('A. php ');
$ Filesname = 'Your file .txt ';
$ Txt = file ($ filesname );
Foreach ($ txt as $ row ){
$ Text = $ text. $ row .'
';}
When footer1_file_get_contents('footer.html ');

Switch ($ classid)
{
Case '1 ':
$ Classname = 'East ';
Break;
Case '2 ':
$ Classname = 'South ';
Break;
Case '3 ':
$ Classname = 'West ';
Break;
Case '4 ':
$ Classname = 'North region ';
Break;
Default:
$ Classname = 'Others ';
};
} Else {
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location:/error.html ");
};
?>




<? Php echo $ title;?>















How can we optimize PHP code to make browsing faster?
A. is it better to use data in php?


------ Solution --------------------
There is no need to optimize these lines of code.

You cannot feel the effect after optimization.
------ Solution --------------------
In a file, it is optimal not to include nested content.
------ Solution --------------------
The most important thing to optimize this code is the format. the code that does not pay attention to indentation is the most ugly.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.