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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    why would you put a "&" infront of a variable

    Does anyone know why there is a "&" infront of the $con variable
    PHP Code:

    $con 
    null;

    function 
    db_connect(&$con$dbName$userName$pwd) {
        
    $con mysql_connect($localhost$userName$pwd);
        if (!
    $con) {
            die(
    'Could not connect: ' mysql_error());
        }
        
    mysql_select_db($dbName$con);


  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Normally, any alterations made to that var within the function would remain local to the function var. Using the & makes any changes to the var global, so to speak.

  • Users who have thanked MattF for this post:

    kevinkhan (11-04-2010)

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MattF View Post
    Normally, any alterations made to that var within the function would remain local to the function var. Using the & makes any changes to the var global, so to speak.
    thanks now i understand

  • #4
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    can anyone explain what the json_decode function does

    and some of this other code. i cant make sense of it

    PHP Code:
        $page str_ireplace('for (;;);'''$page);
        
        
    $json_output json_decode($page);
        
        
    $tmp1 '"pb_'.$profileid.'",';
        
    $tmp2 ', 100, "Profile");';
        
    $tempstr substr($json_output->onload[6], strpos($json_output->onload[6],$tmp1)+strlen($tmp1), strpos($json_output->onload[6],$tmp2)-strpos($json_output->onload[6],$tmp1)-strlen($tmp1)) ;

        
    $json_output json_decode($tempstr);
        if(
    $json_output[0]->entities) {
            foreach(
    $json_output[0]->entities as $e) {
                
    $linkCnt++;
                
    addToReqTable($curl_handle$con$e->href.'&v=info'$cityList$checkReq$profileCnt);
                
    $profileCnt++;
            }
        } 

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't want this to come out the wrong way ...
    But, it's a good idea to use Google first ... because it's faster to get an answer.

    http://www.google.com/search?source=...earch&aq=f&oq=

  • #6
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts

  • #7
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,419
    Thanks
    68
    Thanked 102 Times in 101 Posts
    Common OOP


  •  

    Posting Permissions

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