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

Problems with returning true or false in eval()'d code
Hi guys,

Would appreciate some help with a problem when running eval() on a function that sho

ereg_replace()
Basically what i need to do is

$title = "This Suck's"

$striped = ereg_repl

RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai

Simple email form - Newbie
Hello all,

First time poster!

I've been asked to create a simple HTML form that submit

URL Rewrite issue
Im created a series of Rewrites and on page checks to make sure the correct url is being called. But

Form always sends to error page...
Hello,
Any help will be greatly appreciated. I am having trouble getting multiple fields to be re

PHP Function Page Advice
Hi All, I am quite new to PHP and Javascript but have written an Online Shop (Mainly for Fun and edu

Undefined index on my form
ok im getting Undefined index on this line.. print_r($_REQUEST['form']);

below is the full sc

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

I would like "for" to wait 5 sec
I would like my 'for' loop to wait 5 sec before second iteration.


for ($i=0; $i<10

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