What to do if php cannot load js css

藏色散人
Release: 2023-03-13 18:46:01
Original
3003 people have browsed it

Solutions for php unable to load js css: 1. Check whether the loaded path is correct; 2. Forbid the use of absolute paths; 3. Use relative paths to load files.

What to do if php cannot load js css

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What should I do if php cannot load js css?

Solution to the problem that php cannot load js css:

1. The path must be absolutely correct. Based on the location of the js and css files after the project, the path must be Absolute path

(For example, the project location is under D://studys/aa/bb, the project name is cc, and the js file path is D://studys/aa/bb/cc/public/js/ dd.js, then the loading path should be aa/public/js/dd.js)

2. Do not use absolute paths! ! Don't use absolute paths! ! Don't use absolute paths! !

(Because the absolute path is used, after the file is placed on another computer, the js and css files cannot be loaded because the system disk where we store the php file is very likely to be different)

3. When we use relative paths, we must be good at using the global variable $_SERVER to obtain them. Generally, dirname($_SERVER['SCRIPT_NAME']) is used to load these files

   ($_SERVER[' SCRIPT_NAME'] obtains the relative position of the inde.php entry file, where dirname() refers to the previous path relative to inde.php)

                         atic for $_SERVER['SCRIPT_NAME']                           ulatetaining the relative position of the inde.php entry file, where dirname() refers to the previous path relative to inde.php (for example, the result obtained by $_SERVER['SCRIPT_NAME'] is: aa/bb/cc/index.php, then the result of dirname($_SERVER['SCRIPT_NAME'] is: aa/bb/cc. This result generally intercepts the frame name position - the final position of Index.php is in the frame Folder)

       

             ##                     ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Recommended learning: "###PHP Video Tutorial###"###

The above is the detailed content of What to do if php cannot load js css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!