• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

get-state.php is included as JS file

I know almost nothing about php. however, I do have a strong impression, it is a server side scripting language. I just read this readme file which seems to be saying you should include some .php script inside an html file as a .js.

get-state.php is included as JS file in the header of any page that needs state information.
save-state.php is included in every page of the application, including pages loaded via ajax.

can someone give me a clue. does that mean the .php script actually runs in the browser?
  • 2
2 Solutions
no PHP scripts run on server side and then the output is send to your browser.

So PHP scripts can generate html but HTML sites cannot include php scripts.

But you can do something like this.

in some php file for example

you can have all your html code and then
include get-state.php;

But please read a little bit on php.net
Hi bhomass,

Php is indeed a server side language. It is usually used to generate html / web pages, but it can also generate javascript, pdf or flash files (among others) as well.
What your tutorial is mentioning is that the php scripts for your state handling should be interpreted by your browser as javascript and that you should include them using script tags:
<script type="text/javascript" src="get-state.php"></script>

Kind regards

bhomassAuthor Commented:
I see, I think. you are saying get-state.php will be executed on the server, and the javascript it generated will be loaded onto the browser via
<script type="text/javascript" src="get-state.php"></script>.??
That is correct. The php generates some javascript which in turn is loaded into the browser and being evaluated.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now