Jump to content

Class question?

  • Please log in to reply
4 replies to this topic

#1 Guest_askjames01_*

  • Guests

Posted 29 April 2006 - 08:40 PM

OK, i think i'm starting to full in love with the CLASS.


is this mean assignment;
fetch properties from getlanguages() and assign them into $mg2 'Class'?


simply call getlanguages(); function to execute?

Which do you think are correct? or are they all wrong and you have a much more
better idea? then let me know? please i need to master CLASS.

any help will be very appreciated... thanks n advance.

#2 ToonMariner

  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 29 April 2006 - 10:31 PM


first off - if this is out side the class then unless you have instantiated a class and given it the identifier $mg2 then it will throw an error.

So first you would need something like...

$mg2 = new YourClass;

now if you simply had


then providing that function was defined in your class it will be 'executed' but unless you have anything in you function to perform anything - like set a session var or print info or something it won't help you much. For example - if the function simply queried the database for what languages were installed and nothing else you could not access any of that info.

now if you did...

$info = $mg2->getlanguages();

this would return teh result of the function and you now have access to it so you can do 'stuff'.
follow me on twitter @PHPsycho

#3 Guest_askjames01_*

  • Guests

Posted 30 April 2006 - 03:24 AM

I don't want to argue with this code, because it came from a photogallery script
which i'm currently studying piece by piece & code by code and the entire script
run very well without error.

here take a look for yourself;

[a href=\"http://www.askjames01.com/photogallery/\" target=\"_blank\"]php photogallery script[/a]

so i assume that single line of code works very fine.
and then base on your explanation this is an execution right?

#4 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 April 2006 - 07:40 AM

Yes what the code does is execute the function getlanguages in the mg2 class.
I think what getlanguages() function does is gets all the lanaguges from a database and then stores them in a variabale in side the mg2 class.

#5 Guest_askjames01_*

  • Guests

Posted 30 April 2006 - 10:28 AM

you are really qualified to be a moderator wildteen88!
eric really knows the right person to be a moderator.

thanks again wildteen.

cheers. :)

i hope i can reach your level of programming, i'm so determine to be an elite programmer too...
although i'm a little late already but i don't want to lost hope...

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users