SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    BLYAT! theGWS's Avatar
    Join Date
    Jun 2001
    Location
    Melbourne, AU & Seattle, WA
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is the value of this variable?

    I'm disecting someone's code and need an explanation. Please tell me what the value of $String is.
    PHP Code:
    function parse_this($some_text
    {
        
    $String load_this($some_text$String);

    The variable $String has never been declared so I'd guess it has no value. I don't understand how can it be passed as a parameter into the load_this function when it's never been used before. It's probably a PHP technique that I'm not familiar with yet so if anybody can explain, please do.
    ~Dorian

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It could be passing by reference, that was in the function they could assign a vlue to $String and then it'd be set but then it makes no sense to return a value from the function. Either way it's probably not the best coding practice but if you could post at least the declaration for load_this() it'd help

  3. #3
    BLYAT! theGWS's Avatar
    Join Date
    Jun 2001
    Location
    Melbourne, AU & Seattle, WA
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function load_this($some_text$String
    {
        
    $File $some_text ".txt";
        
        
    $String = @file($File);
        if(
    is_array($String))
        { 
            
    $String implode("",$String); 
        }
        
        return 
    $String;

    ~Dorian

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Well the second argument does absolutely nothing as far as I can see.

  5. #5
    BLYAT! theGWS's Avatar
    Join Date
    Jun 2001
    Location
    Melbourne, AU & Seattle, WA
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly what I thought. Thanks for clearing that up.

    BTW, does that mean any superfluous parameter that gets passed to a function is simply ignored?
    ~Dorian

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I'd imagine so, it wouldn't do anything.


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
  •