get-state.php is included as JS file

Posted on 2007-10-14
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
    LVL 11

    Assisted Solution

    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
    LVL 49

    Expert Comment

    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

    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

    That is correct. The php generates some javascript which in turn is loaded into the browser and being evaluated.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to count occurrences of each item in an array.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now