Dought

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
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

Dought

Post by myharshdesigner »

When we use this

Code: Select all

$this = $smtp_conn;
so why should we use this :-

Code: Select all

$this->smtp_conn
?

any good tutorial for

Code: Select all

->
icon.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

designer ? Its going to be really tough to get hang of OOP concepts if you're not in the hang of programming.

I would suggest you start with C++ or C# and then get back to PHP because C++ and C# are strictly OOP and not loosely type like PHP and Python which makes it easier to fall back to procedural style if you cant come up with an OOP solution.
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

Post by myharshdesigner »

anjanesh wrote:designer ? Its going to be really tough to get hang of OOP concepts if you're not in the hang of programming.

I would suggest you start with C++ or C# and then get back to PHP because C++ and C# are strictly OOP and not loosely type like PHP and Python which makes it easier to fall back to procedural style if you cant come up with an OOP solution.
sir i know -> this means pointing something. but can u explane me in details pl
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

anjanesh wrote:C++ and C# are strictly OOP
Not true at all. Java is strictly OOP. C++ is just like PHP in the sense that you can program with or without objects.

The PHP Manual is the best place to understand the syntax. The first few chapters teach you the basics of the language, but they do assume that you are already familiar with other programming languages. I agree with anjanesh in that making PHP your first language doesn't make it easy to understand all of the concepts, because PHP doesn't not support it all. It is still growing.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

The problem with learning OOP concepts straight from PHP is because of the differences between PHP4's OOP model and PHP5's OOP model. It definitely would confuse others.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

anjanesh wrote:I would suggest you start with C++ or C# and then get back to PHP because C++ and C# are strictly OOP and not loosely type like PHP and Python which makes it easier to fall back to procedural style if you cant come up with an OOP solution.
I disagree, If you are just trying to play around with PHP and OOP messing around (Or learning) via PHP is not a bad thing.

...oh, and to answer your question... :roll:

Code: Select all

<?php 

class Foo{
	var $xyz;
	
	function Foo(){
		$this->xyz = 'blah';
	}
	
	function getXYZ(){
		return $this->xyz;
	}
}

$myObj = new Foo();

echo $myObj->getXYZ();
echo '<br />';
echo $myObj->xyz;

?>
Would output:
blah
blah
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

anjanesh wrote:The problem with learning OOP concepts straight from PHP is because of the differences between PHP4's OOP model and PHP5's OOP model. It definitely would confuse others.
PHP4 and PHP5 are essentially the same. Certainly use of '->' is identical in both -- it references a function or property in an instantiated object.
(#10850)
Post Reply