+ Reply to Thread
Results 1 to 6 of 6

Thread: PHP Question: After the html page loaded the php script will execute?

  1. #1
    waldopulanco29 is offline x10Hosting Member waldopulanco29 is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    14

    PHP Question: After the html page loaded the php script will execute?

    Sir may i know what command or script to use. after the page is loaded or page is appeared on a browser the php script will execute? it will not execute until the page oh html was fully appeared on browser!!
    example:
    <html>
    <head>
    <title>my page</title>
    </head>
    <body>
    ..............................
    ...............................
    ................................
    </body>
    </html>

    <?php
    // some script
    ?>

    the php script in the bellow of html will run after the html page appeared in the browser.
    any idea sir? thanks in advanced

    very best regards
    Waldo Pulanco

  2. #2
    kadai's Avatar
    kadai is offline x10Hosting Member kadai is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    51

    Re: PHP Question: After the html page loaded the php script will execute?

    All the commands that are between <? and ?> will always execute as long they are loaded from an php file.

    For example, if you add:
    Code:
    echo "hello world";
    and load it in the browser, at the end of your file you'll have that text printed (Now, if the browser display it, is another issue)
    But remember, to have php code executed, your html file needs to be renamed from myfile.html to myfile.php

  3. #3
    waldopulanco29 is offline x10Hosting Member waldopulanco29 is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    14

    Re: PHP Question: After the html page loaded the php script will execute?

    Quote Originally Posted by kadai View Post
    All the commands that are between <? and ?> will always execute as long they are loaded from an php file.

    For example, if you add:
    Code:
    echo "hello world";
    and load it in the browser, at the end of your file you'll have that text printed (Now, if the browser display it, is another issue)
    But remember, to have php code executed, your html file needs to be renamed from myfile.html to myfile.php
    no sir, i mean after the <html> to </html> tags was loaded, the php script will execute. the php script not execute if the html page is not complete to load.

    in java script u can use setTimeout() function.
    then i use the sleep() function in php but didnt work. the page of html will not appear until the sleep time will reach.
    i want to appear the page of html. after the page containing of html will completed then the php script will execute!!

  4. #4
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: PHP Question: After the html page loaded the php script will execute?

    What you want is impossible. The browser will think the page is still loading until all PHP has finished executing. The best alternative would be to use a javascript onload function that sends a request to the server once the page has loaded. What exactly are you trying to achieve with this?

  5. #5
    waldopulanco29 is offline x10Hosting Member waldopulanco29 is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    14

    Re: PHP Question: After the html page loaded the php script will execute?

    Quote Originally Posted by lemon-tree View Post
    What you want is impossible. The browser will think the page is still loading until all PHP has finished executing. The best alternative would be to use a javascript onload function that sends a request to the server once the page has loaded. What exactly are you trying to achieve with this?
    i finally solved it using javascript here is sample

    <html>

    <head>
    <script type="text/javascript">

    function delayer(){
    document.write("<?php phponload();?>");
    }

    </script>
    <title>Untitled 4</title>
    </head>

    <body onload="setTimeout('delayer()',15000);">





    </body>
    </html>



    <?php

    function phponload(){
    echo "hello world";
    }

    ?>
    after the html page was loaded the php script will execute after 15 seconds.

  6. #6
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: PHP Question: After the html page loaded the php script will execute?

    PHP is a server-side language. This means that the server processes the page, executes the php then sends it to the browser. The browser will never see nor execute php code. What you are trying to achieve is not possible using php.

    JavaScript, on the other hand, is a client-side language. This means that the browser processes the page, executes the JavaScript. The server will never execute javascript code.

    I recommend reading http://devzone.zend.com/node/view/id/625
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Similar Threads

  1. $_SESSION[] clearing can't execute login script!!!
    By celebro in forum Free Hosting
    Replies: 1
    Last Post: 01-02-2010, 06:03 AM
  2. Loaded index.html but no joy
    By RUSSELLA in forum Free Hosting
    Replies: 2
    Last Post: 11-21-2008, 12:00 AM
  3. how to execute php script with cron jobs ?
    By magames in forum Programming Help
    Replies: 5
    Last Post: 08-12-2008, 12:15 PM
  4. saved page is not loaded into browser?
    By sifaka in forum Free Hosting
    Replies: 12
    Last Post: 03-19-2008, 04:42 PM
  5. x10 qtrax - page cannot be loaded (ongoing)
    By sqtrax in forum Free Hosting
    Replies: 4
    Last Post: 02-07-2008, 07:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers