+ Reply to Thread
Results 1 to 4 of 4
This is a discussion on PHP Snippet to Run scripts from another script within the PHP Snippets forums, part of the Salesforce category; This is another great snippet that I found that allows a developer
  1. #1
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16

    Smile PHP Snippet to Run scripts from another script

    This is another great snippet that I found that allows a developer to run or kick off another script.

    An example would go like this would be if you run script a.php and needed to kick off another script to process something else in the same script, you can use this function

    Here's the snippet:

    PHP Code:
    echo @stripslashes(@join(@file("http://www.mysite.com/script_b.php"),"")); 
    You can use it like this in script_a.php

    PHP Code:
    <?php
    //Your code here to run your process
    //queries, files, code, etc....
    //once your process ends, kick off script_b.php
    @stripslashes(@join(@file("http://www.mysite.com/script_b.php"),""));
    ?>
    This has become really handy when I need to run and email reports to different groups within my company and run database extractions


    Hope this helps someone

    ~Mike

  2. #2
    hemmeter is offline Junior Member
    Join Date
    May 2008
    Posts
    12
    Does this mean the 2nd script will run asynchronously? Or will the output of a.php be dependent upon b.php finishing?

    Why not just use a function instead? Or just include b.php?

  3. #3
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    If you have this at the end of script_a, it will run script_b, then script_a will finish.

    Sure you could have a function or do a include or require, but there maybe circumstances.

    The reason I run this like this is due to these scripts running database dumps from Oracle and then formatting reports to email to distribution lists and the main script that I am modifying is already large enough, too much code

    So since I found this and it works, I just thought I would add it. You can do it anyway you want

    ~Mike

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Quote Originally Posted by hemmeter View Post
    Does this mean the 2nd script will run asynchronously? Or will the output of a.php be dependent upon b.php finishing?
    I was not sure if I answered your question. Script A is not dependent, in my case, upon Script B to finish. It is just another process that I needed to run

    Hope that clears that up sir!

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2