withinweb

Information and support for products of withinweb.com

withinweb header image 4

Entries Tagged as 'Classes'

Differences between PHP4 and PHP5

June 21st, 2012 · No Comments

This listing of the differences between PHP4 and PHP 5 is is probably something that is quite common, but it is always worth a review.
PHP5 is a lot different than PHP4 with the main differences being in how it handles objects and classes.
Here are 10 major differences between PHP4 and PHP5 that you need to [...]

[Read more →]

Tags: Classes

Simple example of a class in PHP

June 20th, 2012 · No Comments

A simple example of a class in PHP
<?php # person
class person {
public function __construct( $name, $age, $height, $weight )
{
$this->name   = $name;
$this->age    = $age;
$this->height = $height;
$this->weight = $weight;
}
// functions that return information
public function get_name()
{
return $this->name;
}
public function get_age()
{
return $this->age;
}
public function get_height()
{
return $this->height;
}
public function get_weight()
{
return $this->weight();
}
// functions that change the object.
public function change_name( $name )
{
$this->name = $name;
}
public function [...]

[Read more →]

Tags: Classes · General PHP

Simple class definition in PHP

June 7th, 2012 · No Comments

Here is a simple class definition in PHP
<?php
class Box {
private $_length;
private $_width;
private $_height;
public function Box($length, $width, $height) {
$this->_length = $length;
$this->_width = $width;
$this->_height = $height;
}
public function volume() {
return $this->_length * $this->width * $this->_height;
}
}
//Example of using the class
$myBox = new Box(20,10, 5);
$myVolume = $myBox->volume();
echo($myVolume);
?>
The definitions of each access modifier :
• public. Public members can be accessed both [...]

[Read more →]

Tags: Classes · General PHP