15c04-1.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 24 行
PHP
24 行
<?php// Create a data structure in memory:$orig = array( array('name' => 'Dierdre', 'category' => 5), array('name' => 'Cheryl', 'category' => 3, 'spouse' => 'Bob'), array('name' => 'Fergus', 'category' => 3, 'spouse' => 'Glynis'), array('name' => 'Jonathas', 'category' => 2, 'spouse' => 'Amalia'), array('name' => 'SCA', 'type' => 'group', 'year' => 34) );// Write it to a file, serialized, using locking to avoid conflictsfile_put_contents('output.ize', serialize($orig), LOCK_EX);// Now read it all back in and unserialize it at the same time:$new = unserialize(file_get_contents('output.ize'));// Echo out the first entry's name ('Dierdre')echo "First entry is: {$new[0]['name']}<br />";// Now just go ahead and dump the entire structure to the screen:echo '<pre>';var_dump($new);echo '</pre>';?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?