Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2073 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

PHP - Object

Thread title: PHP - Object
Closed Thread    
    Thread tools Search this thread Display Modes  
10-29-2007, 11:31 AM
#1
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old  PHP - Object

I've got a problem with a script I'm trying to modify.

I don't know much about objects, I always tend to use arrays.

If I do the following

PHP Code:
print_r($_SESSION['emf1_controller']); 
I am left with;

Code:
__PHP_Incomplete_Class Object
(
    [__PHP_Incomplete_Class_Name] => controller
    [myErrorPage] => phpErrorCheck.php
    [dbh] => 0
    [user] => stdClass Object
        (
            [user_userId] => 1000
            [user_firstname] => Mick
            [user_surname] => Sketch
        )

)
I want to try and access the user_firstname field.

I've tried a few different things like

PHP Code:
echo $_SESSION['emf1_controller']['user']->user_firstname 
and a lot of other things and none seem to work. Can anyone help me access this field?

10-29-2007, 12:23 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

The problem here is that the controller class definition is not available to your PHP script. You'll need to include it in there so that PHP knows how to handle the object.

Once you've included the class definition, you can access the first name using:
$_SESSION['emf1_controller']->user->user_firstname

10-29-2007, 12:33 PM
#3
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

Thank you worked well.

Cheers

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed