Ben dizeleri basit şifrelemek ve şifresini bu iki sınıfları yazdı:
Encode.php class Encode { protected funcion do_encode($string) { .. } } Decode.php class Decode { protected funcion do_decode($string) { .. } }
Ne would yapmak gibi olduğunu:
Encrypt.php class Encrypt extends Encode, Decode { protected $stuff_for_parents; function __construct($configs) { $this->stuff_for_parents = $configs['SomeConf']; } public function encode($string) { $this->do_encode($string); } public function decode($string) { $this->do_decode($string); } }
But we cannot include more than one class, so: fail.
Now my questions are:
- Bir tasarım sorunu var mı? , Bu senaryo bana garip görünmüyor Neden öyle?
- Farklı sınıflarda işlevlerini kullanan bir nesne olması için başka bir yolu var mı? Sıralama
$encrypt->encode($str);
$encrypt->decode($str);