PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
<?php
class Person
{
var $name;
var $salary;
}
$p = array()
$p[0] = new Person;
$p[0]->name= "jax";
$p[0]->salary= 1000;
print_r($p[0]);
?>
This gives me an error as "Parse error: syntax error, unexpected T_VARIABLE in C:\webs\test\object.php on line 9"
Can anyone tell me how to create an array of objects of the class Person??
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
<?php
class Person
{
var $name;
var $salary;
}
$p = array()
$p[0] = new Person;
$p[0]->name= "jax";
$p[0]->salary= 1000;
print_r($p[0]);
?>
This gives me an error as "Parse error: syntax error, unexpected T_VARIABLE in C:\webs\test\object.php on line 9"
Can anyone tell me how to create an array of objects of the class Person??
1. Read the error message. It tells you what's wrong with your script. If it says there was a parse error that means you've got some syntax wrong somewhere.
2. It's a good idea to have methods in your object to get and set variables rather than setting them from 'outside'.
Actually I had done other forms of somersaults to get this . I had created
This simple example to post on the forum.....
Surprised that this is correct....
Thanks any way fr ur attention though!!!