Trouble with function calls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Huether

    #1

    Trouble with function calls

    This relates to my previous posts about protecting mp3 files.

    I have forgotten a lot of my
    PHP knowledge. For istance, say I have a file called audio.php that contains

    <?php

    function ServeAudio($fil e) {

    echo $file;
    //header("Locatio n: " .$file);

    }
    ?>

    To test it, I have a file called audiotest.php that contains

    <body>
    <a href = "audio.php?op=S erveAudio&file =
    <?php
    echo "http://blah.mp3";
    ?>">file</a>
    </body>

    But I can not get it to successfully enter the ServeAudio function.

    thanks,

    brian



  • naixn

    #2
    Re: Trouble with function calls

    Brian Huether wrote :
    This relates to my previous posts about protecting mp3 files.
    >
    I have forgotten a lot of my
    PHP knowledge. For istance, say I have a file called audio.php that contains
    >
    <?php
    >
    function ServeAudio($fil e) {
    >
    echo $file;
    //header("Locatio n: " .$file);
    >
    }
    ?>
    >
    To test it, I have a file called audiotest.php that contains
    >
    <body>
    <a href = "audio.php?op=S erveAudio&file =
    <?php
    echo "http://blah.mp3";
    ?>">file</a>
    </body>
    >
    But I can not get it to successfully enter the ServeAudio function.
    >
    thanks,
    >
    brian
    >
    >
    >
    Well... Here you're nowhere calling the ServeAudio function in the audio.php
    file.
    Here what you should do :

    1/ First solution :
    <?php

    echo $_GET['file'];

    ?>

    2/ Second solution, if you have different functions to call :
    <?php

    function ServeAudio($fil e)
    {
    echo $file;
    }

    function BlahBlah($file, $nb)
    {
    echo 'the' . $nb . $file;
    }

    $func = $_GET['op'];
    unset($_GET['op']);
    call_user_func_ array($func, $_GET);

    ?>

    --
    Naixn

    Comment

    Working...