beginner question

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!

Moderator: General Moderators

Post Reply
aabvg
Forum Newbie
Posts: 2
Joined: Tue Aug 17, 2010 5:22 pm

beginner question

Post by aabvg »

code :
<?php
class A {
$a=1;
function Aa ( ) {
echo " Aa cal l" ; }

}
$A = new A;
$A-> Aa();
$A-> $a;
?>
display notice :
Parse error: parse error, expecting `T_FUNCTION' in C:\Program Files\EasyPHP5.3.0\www\moji sajtovi\proba vezbe.php on line 3

what is wrong with $a=1; ?
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: beginner question

Post by shawngoldw »

Inside of classes you need:

Code: Select all

var $a = 1;
You need this for class variables, but not inside of the functions within a class.


Shawn
aabvg
Forum Newbie
Posts: 2
Joined: Tue Aug 17, 2010 5:22 pm

Re: beginner question

Post by aabvg »

thanx shown
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: beginner question

Post by shawngoldw »

denovank wrote:var is for php 4 I would say it's deprecated. If you learn php5, go with public, private... in replacement for better variable scope.
I use php5 and did not know that. Thanks for the tip!
Vethalam
Forum Newbie
Posts: 1
Joined: Thu Aug 19, 2010 3:44 am

beginner question

Post by Vethalam »

Hi Guys Im in New In PHP, Xampp...I want to learn and develop in php...
I know little HTML, JS,JavaScript,Java

Now i install XAMPP...
But i dont know how to start....

i want design a simple form
dont know start where,how,which....

Pls Just give a intro........i will pckup.......

Thanks in advance
Post Reply