Q: Is it more efficient to use php tags to generate html Tag hyperlinks (href/src) than to write them directly?

Source: Internet
Author: User
Sometimes some online and offline things may have different paths. it will be similar to writing {code ...} but I am thinking, sometimes it is necessary to make the website static. is this method not applicable? If the web page must be static, how can we solve the problem of different online and offline paths? There is something simple... sometimes the path of some online and offline things may be different. It will be similar to this.

// A. php file
  Main.css? 7.1.1 "rel =" stylesheet ">

But I was wondering, sometimes it is necessary to make the website static. Isn't this method applicable? If the web page must be static, how can we solve the problem of different online and offline paths? Is there any easy way to solve this problem? It's like jade in node. js is directly rendered by a template?

In addition, if a page is nested with many tags like this, will the webpage loading efficiency be reduced?

I just learned php QAQ soon. I have little knowledge.

Reply content:

Sometimes some online and offline things may be stored in different paths.

// A. php file
  Main.css? 7.1.1 "rel =" stylesheet ">

But I was wondering, sometimes it is necessary to make the website static. Isn't this method applicable? If the web page must be static, how can we solve the problem of different online and offline paths? Is there any easy way to solve this problem? It's like jade in node. js is directly rendered by a template?

In addition, if a page is nested with many tags like this, will the webpage loading efficiency be reduced?

I just learned php QAQ soon. I have little knowledge.

Php labels filled with html are actually very fast to run, and the impact of running speed can be completely ignored.
So you can write a config. php file that declares various paths.
For example


  

Then you can use. htaccess to automatically include or manually include this file. In this way, you only need to modify the config. php file to update the path of the entire project.

As long as php does not support short tags in the antique version, you can write the following brief:


  

If you are unhappy, you can write a script to replace all the constants with the desired address, and run it once during redeployment.

I just saw that you asked how to update the entire file as compiled.

If you are stupid, search the entire project folder. Replace it with what you want.
Enter During deployment, all the code is copied and each variable is replaced with a script.

The main purpose is to improve code migration and some development issues.
For example, we can use 1 to indicate that it has been installed. Why do we have to use a constant to express it?
1. improve readability
2. Although the standard is fixed, it cannot be changed, but when there are changes that have to be made, you may want to die if you use 1.
The same is true for this problem.

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.