Showing posts with label documentation. Show all posts
Showing posts with label documentation. Show all posts

Tuesday, July 29, 2008

Clarification of Encapsulation in PHP - OOP

PHP Developer - Boston, MA | Object Oriented Programming

Here is a demonstration of what is happening to an object member while changing it. This should help you clarify how PHP handles pointers:


class A {
public $val;

public function __construct( $val ) {
$this->val = $val;
}
}

class B {
public $val;

public function __construct( $val ) {
$this->val = $val;
}
}

$a = new A(5);

echo $a->val; // 5

echo "
";

$b = $a;

$b->val = 10;

echo $a->val; // 10

$c = clone( $a );

$c->val = 15;

echo "
";

echo $c->val; // 15

echo "
";

echo $a->val; // 15

echo "
";

$z = 1;

echo ++$z * $z++ + $z; // 7

echo "
";

echo $z; // 3

echo "
";

$m = 0;
do {
echo $m;
} while ( ++$m < 10 );


Friday, July 4, 2008

PHP

PHP is a scripting language particularly designed for web development. It can be used for some server administration as well. There are many pros and, unfortunately, many cons for using PHP. Some of the pros are that it is free, open-source, easy-to-use, powerful, easy to find code samples, tutorials, and documentation, and many others. Some of the cons are that it is easy to write "bad" code with, it is slow, it is hard to find out what your code is doing internally, and bugs can potentially exist. PHP is widely used and respected amongst the development community. PHP 5 has the power to be object-oriented and PHP 6 is even heading further in that direction. It is easy to set PHP up on a Linux, Mac, or Windows machine. It works seamlessly with Apache, MySQL, and PostgreSQL.

PHP Developer - Boston, MA