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

delete comma
HI,

How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr

Using the $_GET variable to view certain records
Hello,

First let me explain my problem, I have 2 pages the first page pull a list of Guide ti

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

help finding hacking loopholes
i was attacked by a redirect php injection

my pc is clean of viruses

so i figure that

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

LSB (PHP 5.3) problem with static value!
hello,

i'm having a problem. static::$text variable gets lost at some point. can someone plea

Connecion issue
Hi,

For some reason, I keep getting this error when trying to connect:

Warning: mysql_

Can you help please? Php file
I have to write this php file to allow users to register their nicknames on nickserv

For an I

Hom to make one url to open together with another url
I have a chat, which i want to be opened, as soon as the users login to the site. As it is now, when

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