php can not load js css solution: 1, check the correct path to load; 2, prohibit the use of absolute path; 3, use relative path to load the file can be.
What if php can't load js css?
The solution of php can not load js css:
1.The path must be absolutely correct, based on the project after the js, css file location path must be an absolute path
For example, if 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 load path should be aa/public/js/dd.js
2.Don't use absolute paths
Because of the absolute path, after the files are placed on other computers, the js and css files will not be loaded, because the system disk where we store the php files is very likely to be different
3.When we use relative paths, we have to be good at using $_SERVER as a global variable to get them, generally loading these files using dirname($_SERVER['SCRIPT_NAME'])
$_SERVER['SCRIPT_NAME'] gets the relative location of the inde.php entry file, where dirname() means relative to a path on inde.php
For example $_SERVER['SCRIPT_NAME'] gets the result: aa/bb/cc/index.php, then dirname($_SERVER['SCRIPT_NAME'] gets the result: aa/bb/cc, this result is generally intercepted to the frame name location - -Index.php final location in the framework folder, at this time, we then according to the results obtained, and we place js, css file location, a splice, we can get access to js, css file relative path