understanding functions and classes


Posted on 16th Feb 2014 07:03 pm by admin

Code: [Select]
class person {
var $name = "Jimmy Goe";

Did you know?Explore Trending and Topic pages for more stories like this.
function get_name(){

echo $this->name;
}
}

I am playing with this very small script that I made using a tutorial. I can get the script to echo out the name using the code above. What I don't get is why I can't do this

Code: [Select]class person {
var $name;

function get_name(){
$name = "Jimmy Goe"
echo $this->name;
}
}

then of course in my index page, I am calling it like this
Code: [Select$joe = new person();

$joe->get_name();

If you decide to answer this question, please be as detailed as possible, I am a newb as you can see and the more information you give or the simpler the explanation, the better.

Thanks for helping
No comments posted yet

Your Answer:

Login to answer
113 Like 33 Dislike
Previous forums Next forums
Other forums

The IE or FF detector
Hello Friends,

Problem of today ( we seek for php help ) as following ,

we know all th

FROM_UNIXTIME($phpdate);
Hello,

I tried to use this :

$date = FROM_UNIXTIME($phpdate);

ANd I was t

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

UL and LI Add Form
The idea I want here is when the user click on a character name from the drop down select bar at the

I didnt code this but I need help with it
I'm sorry. i'm not a coder. I have this script for forcing download and previewing mp3. The guy that

fwrite error
Hi All,
Does anyone know what is causing the error in this code?

Code: <?
$error

PHP submit form script causing blank page
Im trying to submit a form using this script, however nothing shows up on the page, does anyone know

Multi-user card game
I'm writing a batch of games and such. Lottery is finished, Poker,blackjack,etc are next. They will

Code Review - SQL and Insertion Attacks (Warning: Not for Newbs)
Hey guys,

Its been a while, I know. Use to love coming here to answer peoples questions, but

Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to ret

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash