How to import/include a CSS file using PHP code and not HTML code?

后端 未结 14 1917
無奈伤痛
無奈伤痛 2020-11-28 11:11

I have googled a lot but it seems that I am doing something wrong.

I want to do this:



        
14条回答
  •  我在风中等你
    2020-11-28 11:53

    This is an older post, however as the info is still relevant today an additional option may help others.

    • Define a constant for the file path per Stefan's answer. The definition can be placed at the top of the PHP page itself, or within an included/required external file such as config.php. (http://php.net/manual/en/function.include.php)

    • Echo the constant in PHP tags, then add the filename directly after. That's it!
      Works for other linked files such as JavaScript as well.

    
    
     
    
    
    
    
    
    
    
    
    

提交回复
热议问题