understanding functions and classes


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

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

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

Multi dimensional arrays
If I put in this code:

1
2
3
4
5
6
7
8
9
10
11
12
13<

Cannot Connect to Database
I am writing an application to do annual reviews. I cannot get my script to work. Whenever it runs I

php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th

server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase

Can I call a class inside a function?
I have a class written in another file that handles my image resizing.

Can I do this (php say

Two warning messages
Quote<b>Warning</b>: mysql_real_escape_string() expects parameter 1 to

pspell
using pspell, is it possible to get words that would be best in the current phrase?

For examp

PRotect my POST DATA... FROM HTML ATTACKS
I need to like let's say

If a user submit's his Prayer and he put's <meta refresh stuf

Feed Maker
Hi all.
First of all I must say I am not a php developer so I am afraid I don't know much about i

PHP Login
Hey!
I got this shopcart code online, am trying to modify it but am getting an error when i try a

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