mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
fix #31008: first example had a little bug
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@174277 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
aa43cb1caa
commit
e2c756356f
1 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.55 $ -->
|
||||
<!-- $Revision: 1.56 $ -->
|
||||
<chapter id="language.oop">
|
||||
<title>Classes and Objects (PHP 4)</title>
|
||||
|
||||
|
@ -16,22 +16,25 @@
|
|||
<?php
|
||||
class Cart {
|
||||
var $items; // Items in our shopping cart
|
||||
|
||||
|
||||
// Add $num articles of $artnr to the cart
|
||||
|
||||
|
||||
function add_item($artnr, $num) {
|
||||
$this->items[$artnr] += $num;
|
||||
}
|
||||
|
||||
|
||||
// Take $num articles of $artnr out of the cart
|
||||
|
||||
|
||||
function remove_item($artnr, $num) {
|
||||
if ($this->items[$artnr] > $num) {
|
||||
$this->items[$artnr] -= $num;
|
||||
return true;
|
||||
} elseif ($this->items[$artnr] == $num) {
|
||||
unset($this->items[$artnr]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue