Example of registry (registry) use of the ZF framework

Source: Internet
Author: User
Tags table name zend

  This article mainly introduces the Registry (registry) Use example of the ZF framework, provides an object way to use the example with set, get method, need friend can refer to the following

Simple use   code as follows: <?php require_once ("zend/loader.php"); Zend_loader::loadclass ("Zend_registry"); $ARR = Array (  ' host ' => ' 127.0.0.1 ',   ' username ' => ' root ',   ' password ' => ',   ' dbname ') => ' test '); $Reg = new Zend_registry ($ARR); Echo ' Host name: '. $Reg [' Host ']. "<br>"; Echo ' username: '. $Reg [' username ']. "<br>"; echo ' Password: '. $Reg [' Password ']. "<br>"; echo ' Database: '. $Reg [' dbname ']. "<br>"; echo "<hr>"; Zend_registry::set (' Table name ', ' Sanguo ');  //set assignment method, or you can assign an array of echo zend_registry::get (' table name ');  //get Value method?>     Object mode use with Set, get method use     code as follows: <?php//Introduce loader automatically load class require_once ("zend/ Loader.php "); Load Registry Object class Zend_loader::loadclass ("Zend_registry"); Registry (); Speak $reg convert to Object Format zend_registry::setinstance ($REG); Assign value to $reg (registry assignment) $Reg->name = ' John '; $Reg->sex  = ' male '; $Reg,; age  = ' 18 '; Gets the static object after the output. $Reg = Zend_registry::getinstance (); echo "Name is:". $Reg->name. "<br>"; echo "Sex is:". $Reg->sex. "<br>"; echo "Age:". $Reg->age. "<br>"; /*--------------------------------------------------------/* $Arr = Array (' name ' => ' John ', ' age ' => ' 18 ', ' Hobby ' => ') Online "); Zend_registry::set (' my ', $ARR); Class Person { public function I ()  {  echo "My name is:". Zend_registry::get (' my ') [' name ']. "<br>";   echo "My Age is:". Zend_registry::get (' my ') [' age ']. "<br>";   echo "My hobby is:". Zend_registry::get (' my ') [' Hobby ']. "<br>"; &NBSP}} $Person = new person (); $Person-> my ();?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.