Search code examples
phpexecute

How can I execute two consecutive PHP scripts declared in one single PHP script?


I have two PHP files.

1) Create.php 2) Insert.php

I would like to create a PHP file that executes the previous PHP scripts in a row.

e.g.

    exec(Create.php);
    exec(Insert.php);

Is there any way that I can execute these PHP scripts? Can I create another PHP script that it can execute the previous scripts?

Thanks

Thanks


Solution

  • You simply include them (require is the keyword for this):

    <?php
        require Create.php;
        require Insert.php;
    
        // depending on what the files contain, you can now execute their
        // functions, instantiate their classes, or in case they produce
        // direct output, it will be visible now.
    ?>