Jump to content

Include Php


harshpandya
 Share

Recommended Posts

PHP runs first, and it's output runs at the browser. That's that.You can safely do

<script type="text/javascript">//do something</script><?phpinclude 'something.php';?>

in which case the server will first process "something.php", and finally the browser is going to receive the script, along with the output of "something.php". For example, if "something.php" contained

<?phpecho 'SOMETHING';?>

then the final output would be

<script type="text/javascript">//do something</script>SOMETHING

and THAT is what the browser will see.To answer your question - no, it won't cause any problems, as PHP and JavaScript have nothing to do with each other.

Link to comment
Share on other sites

It has nothing to do with PHP. When it gets to the browser, the PHP output is part of the document, just as if you had hard-coded it there. So if the scripts and functions are arranged in a way that calling them works, it works. If not, not. Same rules as a normal HTML file.What you're saying is the function call is printed above the included material. If it's called from the global space of a script (I mean, not in a function, so the call happens while the script loads), that will be a problem, because the included material hasn't arrived yet--not because it's included, but because it's below. If it's called from a function, like in response to a user action, then that would be after page load, and it should be fine.Did you try it? Are you having a problem? Just trying it should answer your question. If your Firefox error console says that the function doesn't exist, then it's probably the problem I mentioned.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...