link to css and js files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
isaac_cm
Forum Commoner
Posts: 44
Joined: Wed May 17, 2006 8:47 am

link to css and js files

Post by isaac_cm »

Hello,
I have a php file and I need to call some js functions from this file , these functions are located in external js file and also I should link to CSS file

what I should do to link to CSS and js files from inside my php file and my php file doesnt have the html or head or body tags just php code

I tried that:

Code: Select all

<?php
echo '<link rel="stylesheet" href="colorpicker/css/colorpicker.css" type="text/css" />';
echo '<script type="text/javascript" src="colorpicker/js/colorpicker.js"></script>';
?>
and get this error:
Error: missing ; before statement
Source File: http://mysite.com/wp-admin/colorpicker/ ... rpicker.js
Line: 1, Column: 81
Source Code:
<link rel="stylesheet" href="colorpicker/css/colorpicker.css" type="text/css" /><script type="text/javascript" src="colorpicker/js/colorpicker.js"></script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xht
please advice

Thanks
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: link to css and js files

Post by cpetercarter »

Well, where is the html that produces the web page? Put the links in the head section of whatever file it is.
isaac_cm
Forum Commoner
Posts: 44
Joined: Wed May 17, 2006 8:47 am

Re: link to css and js files

Post by isaac_cm »

but no head section , this page called functions.php it used to add options to wordpress theme
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: link to css and js files

Post by jackpf »

You're putting links before the doctype. I don't believe you can do that.
Post Reply