[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


get-state.php is included as JS file

Posted on 2007-10-14
Medium Priority
Last Modified: 2012-08-13
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?
Question by:bhomass
  • 2
LVL 11

Assisted Solution

f_o_o_k_y earned 80 total points
ID: 20076287
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
LVL 49

Expert Comment

ID: 20076526
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


Author Comment

ID: 20080087
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>.??
LVL 49

Accepted Solution

Roonaan earned 200 total points
ID: 20080347
That is correct. The php generates some javascript which in turn is loaded into the browser and being evaluated.


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question