study homework
- require_once("Zend/Loader.php");
- Zend_Loader::loadClass("Zend_Registry");
- $Arr = array
- (
- 'host' => '127.0.0.1' ,
- 'username' => 'root',
- 'password' => '111',
- 'dbname' => 'test'
- );
- $Reg = new Zend_Registry($Arr);
- echo ' Hostname:' . $Reg['host'] . "
";
- echo 'Username:' . $Reg['username'] . "
";
- echo 'Password:' . $Reg['password'] . "
";
- echo 'Database:' . $Reg['dbname'] . "
";
- echo "
";
- Zend_Registry:: set('table name','sanguo'); //SET assignment method, you can also assign the value to an array
- echo Zend_Registry::get('table name'); //GET value method
- ?>
Copy Code
- //Introducing Loader to automatically load classes
- require_once("Zend/Loader.php");
- //Loading registry object classes
- Zend_Loader::loadClass("Zend_Registry");
- /*------------------------------------------------ --------*/
- //Perform registry operations in object mode
- //Assign the resources of the instantiated registry object class to $Reg
- $Reg = new Zend_Registry();
- //Talk about $Reg Convert to object format
- Zend_Registry::setInstance($Reg);
- //Assign value to $Reg (registry assignment)
- $Reg ->name = 'Zhang San';
- $Reg ->sex = 'Male ';
- $Reg ->age = '18';
- //Output after obtaining the static object.
- $Reg = Zend_Registry::getInstance();
- echo "The name is: " . $Reg->name . "
";
- echo "Gender is:" . $Reg->sex . "
";
- echo "Age is:" . $Reg->age . "
";
- /*-------------------------------------------------- ---------*/
- $Arr = array('Name' => 'Zhang San','Age' => '18','Hobby' => 'Internet');
- Zend_Registry::set('My',$Arr);
- class Person
- {
- public function My()
- {
- echo "My name is:" . Zend_Registry::get('My')['Name'] . "
";
- echo "My age is:" . Zend_Registry::get('My')['Age'] . "
";
- echo "My hobbies are:" . Zend_Registry::get('My')['Hobby'] . "
";
- }
- }
- $Person = new Person();
- $Person -> My();
- ?>
Copy code
|