Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that php cannot load js css

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to solve php can not load js css problem", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's make up the following to take everyone to learn "how to solve the php can not load js css problem"!

php cannot load js css solution: 1, check whether the load path is correct;2, prohibit the use of absolute path;3, use the relative path to load the file.

Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer

PHP cannot load JS CSS.

PHP cannot load JS CSS solution:

1, the path must be absolutely correct, based on the project after the js, css file location path must be absolute path

(For example, the location of the project is 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 load path should be aa/public/js/dd.js)

Don't use the absolute path! Do not use absolute paths! Do not use absolute paths!

(Because with absolute path, after placing the file on other computers, js, css files will not load either, because the system disk where we store php files is very likely to be different)

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

($_SERVER ['SCRIPT_NAME'] gets the relative location of the inde.php entry file, where dirname() refers to a path relative to inde.php)

(For example,$_SERVER ['SCRIPT_NAME'] gets aa/bb/cc/index.php, so dirname($_SERVER ['SCRIPT_NAME'] gets aa/bb/cc, which is usually intercepted at the frame name location--Index.php The final location is under the frame folder)

(At this time, we can get the relative path of our access to js and css files based on the results obtained and the location where we place js and css files.)

At this point, I believe everyone has a deeper understanding of "how to solve php can not load js css problem," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report