|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-06 05:28 UTC] coola at arcor dot de
Description:
------------
Hi,
i would like to do something like that:
<?php
class A extends SplInt // extends SplInt
{
protected $x;
protected $y;
public function __construct($x, $y)
{
$this->x = $x;
$this->y = $y;
}
public function splIntMethode($other, $operator) // override SplInt-Methode
{
if($operator != '+')
throw new Exception();
if(!($other instanceof A))
throw new Exception();
return new A($this->x + $other->x, $this->y + $other->y);
}
}
$a0 = new A(1,2);
$a1 = new A(3,4); // $a1 is the '$other'-Objekt at methode splIntMethode
$a2 = $a0 + $a1; // $operator +
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Crashed on my System (PHP 5.5 fpm on OpenSuse) when extending SplType. At least Extension of SplType should be possible. My Code: <?php class ConvChar extends SplType { private $__default = 0; public function __construct($initial_value, $strict = true) { $this->__default = $initial_value; } }