Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: PLEASE help!!!

  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PLEASE help!!!

    how can i pass variables from an function to a include inside it?

    <?php
    // index.php
    function a() {
    $a= 'apples';
    include('fuit.php');

    }

    ?>

    <?php
    // fruit.php
    echo $a;
    ?>

    THANKS!!

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts

    More descriptive subject

    In the future, please use a more descriptive subject when posting a question. See posting guidelines.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    try:

    PHP Code:
    <?php
    global $a;
    // index.php
    function a() {
    $a'apples';
    include(
    'fruit.php');

    }

    ?>

    <?php
    // fruit.php
    echo $a;
    ?>


  •  

    Posting Permissions

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