SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    undefined function????

    here is me prob...

    in me class session, this is the method (well a little of it):-

    PHP Code:
    function session(){
                   if(!isset(
    $session_cookie)){
                       
    $this->user rand_str();
                       echo(
    $this->user);          
                   }

    however on the $this ->user = rand_str(); line it says that rand_str() is a undefined function altho i have definded it later in the class:

    PHP Code:
    function rand_str(){
                   
    $allchar "abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ0123456789";
                   
    srand ((double) microtime() * 1000000);

                   for(
    $i 0$i $user_length$i++){
                        
    $str .= substr($allcharrand(strlen($allchar)), 1);
                   }

                   return 
    $str;
          } 
    am i missing summin' here?????
    beachball

    PS> the echo($thi->user) is for me to see if it's workin'

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As with class variables, methods in the same class must called as $this->methodname

    PHP Code:

    $this
    ->user $this->rand_str(); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx freddy

    one more thing...

    $this->user doesn't seem to take on the value of rand_str please help..

    beachball

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's sorted...

    i change the function u see so took on a parameter for the length of the string and put $length instead of $this->length

    lol, will i ever learn??
    beachball


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
  •