javascript and css in php

TarinC

New Member
Messages
698
Reaction score
0
Points
0
how would i put javascripts and css into php files?

would i just type include(filename) or echo "<script type=blah blah blah src=...>"; or is there a different way?
 

chitwa

New Member
Messages
128
Reaction score
0
Points
0
The second option (echoing) is more practical. I use it anyway and it works fine with me.
 
B

Brandon

Guest
Well you could use this it might make things clearer.

<?php
$java = 'YOURSCRIPT';

echo '$java';

?>
 

randomize

New Member
Messages
674
Reaction score
0
Points
0
I would use the php include function

so somethinglike this:

<?php include("http://www.yoursite.com/script.js"); ?>

My mate uses it and I use it in my sites and it seems to work easy.

Its more pactical as you only have to modify one file and it changes on all pages.

But it is your choice if you want to use the other ways that the other guys mentioned ealier in the thread.
 

moose

New Member
Messages
1,056
Reaction score
0
Points
0
Interesting. So how do you include the CSS in a PHP file than?

I was actually wondering that also.
 

moose

New Member
Messages
1,056
Reaction score
0
Points
0
Are you able to have an external CSS file and call it in?
 

randomize

New Member
Messages
674
Reaction score
0
Points
0
if you wanted an external js file or something you could do:

<script src="blah.js"></script>
<?php include("blah.js"); ?>

If it was to be css

<?php include("blah.css"); ?>


I think that is what you mean, however I could be wrong!!
 
Last edited:
B

Brandon

Guest
Randomize? Do you know what your talking about those examples would not work.
 

randomize

New Member
Messages
674
Reaction score
0
Points
0
Ok maybe your right

But the last time I checked with these methods, they did however work, for some strange reason!!
 
Last edited:

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
why do you guys insist on confusing people?

?> *escape from current php if any*

html, css, javascript

<?php *go back into php

some php

?>
*end of file*

just do that (without the *...*s in there, those are just there so you know what the example means)
 
Top