![]() ![]() $new = & $f3 -> ref ( 'newObj->name' ) $new = 'Sheldon' echo $f3 -> get ( 'newObj' ) -> name // SheldonĮcho $f3 -> get ( 'newObj->name' ) // SheldonĮcho $f3 -> get ( 'newObj.name' ) // Sheldon $new = 'hello world' // set value of php variable, also updates referenceĮcho $f3 -> get ( 'newVar' ) // hello world $new = & $f3 -> ref ( 'newVar' ) // creates new framework hive var 'newVar' and returns reference to it You can also add non-existent hive keys, array elements, and object properties, when 2nd argument is TRUE by default. $b = 'Chuck' // modifiying the reference updates the framework variable 'name' Usage: $f3 -> set ( 'name', 'John' ) $b = & $f3 -> ref ( 'name' ) // $b is a reference to framework variable 'name', not a copy Get reference to hive key and its contents mixed & ref ( string $key ) GET, POST, COOKIE, REQUEST, SESSION, FILES, SERVER, ENV ref If the returned value is a string containing one or more format placeholders, arguments can be passed directly after the key's name: $f3 -> set ( 'var1', 'Current date: ' ) echo $f3 -> get ( 'var1', time ( ) ) //shorthand for $f3->format($f3->get('var1'),time()) Įcho $f3 -> get ( 'var2', array ( $timestamp1, $timestamp2 ) ) //shorthand for $f3->format($f3->get('var2'),$timestamp1,$timestamp2) į3 will automatically sync the following PHP globals: $local_var = $f3 -> get ( 'myVar' ) // $local_var holds the string 'hello world' To get the value of a previously saved framework var, use: $f3 -> set ( 'myVar', 'hello world' ) echo $f3 -> get ( 'myVar' ) // outputs the string 'hello world' Retrieve contents of hive key mixed get ( string $key ) Furthermore, root hive keys are checked for validity against these allowed chars: get There's no need for you to do it by yourself. Notice: If you set or access a key of SESSION, the session gets started automatically. These 8 variables are automatically in synch with the underlying PHP globals. It is also possible to set the PHP globals through F3's COOKIE, GET, POST, REQUEST, SESSION, FILES, SERVER, ENV system variables. You can change them to modify a framework behaviour, for example: $f3 -> set ( 'CACHE', TRUE ) $f3 -> set ( 'HALT', FALSE ) $f3 -> set ( 'CASELESS', FALSE ) The framework has its own system variables. $f3 -> set ( 'm圜lass1', new m圜lass ( 'arg1' ), 3600 ) // change expire time for a single cookie var get() will load them automatically from the cache.Įxamples of caching framework variables: // cache string You can cache strings, arrays and all other types - even complete objects. If you need to cache vars for an infinite time, check the Cache->set method. ![]() Already cached vars will be updated by reusing the old expiration time. If the $ttl parameter is > 0, and the framework cache engine is enabled, the specified variable will be cached for $ttl seconds. Shorter ArrayAccess Syntax, since v3.4.0 $f3 -> LANGUAGE = 'en' $f3 -> foo = 1234 $f3 = 'buzzword' Caching properties Setting object properties: $f3 -> set ( 'a', new \ stdClass ) $f3 -> set ( 'a->hello', 'world' ) echo $f3 -> get ( 'a' ) -> hello // world Setting arrays: $f3 -> set ( 'hash', array ( 'x' => 1, 'y' => 2, 'z' => 3 ) ) // dot notation is also possible: $f3 -> set ( 'd', TRUE ) // d=TRUE, boolean $f3 -> set ( 'c', 'whatever' ) // c='whatever', string ![]() setīind value to hive key mixed set ( string $key, mixed $val )Įxamples of setting framework variables: $f3 -> set ( 'a', 123 ) // a=123, integer Storing a value in the hive ensures it is globaly available to all classes and methods in your application. The hive is a memory array to hold your framework variables in the form of key / value pairs. The file base.php also includes the essential Cache, Prefab, View, ISO and Registry classes to reduce unnecessary disk I/O for optimal performance.įeel free to remove all other files in the lib/ directory, if all you need are the basic features provided by this package. It contains everything you need to run a simple application. The Base class represents the framework core. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |