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

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

Error in write byte array into document in SM58
Hi Gurus,

Getting the following error status in Transactional RFC (SM58) ..... *Error i

Why does this file not return file names that start with numbers?
This file returns a list of filenames to help populate a drop down in my form. For some reason it ig

How to assign a textbox value to PHP variable??
Hi ! Can any one help me out as quickly as possible. As I m new to PHP.
Plz tell me how to assign

Mail form doesn't send Russian/Cyrillic characters correctly?
When someone enters foreign characters (like Cyrillic text, and Japanese/Chinese probably gives the

Modal Popup Help
Hi guys, I have a modal popup with an iframe. How can i send data from a label or textbox to the ifr

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

how do i make a string??
hey guys,
can someone please tell me how to put data from the glob function into a string

Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let s

column name cancatenation within PL/SQL
I have a PLSQL store procedure, and the following statement is part of a subquery
fname||lnam

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