09c02-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 33 行

PHP
33
字号
<?php// Now create a function that will highlight the section you are in:function create_highlighted_sections($secarray) {    // Loop over the entire array, making a basic menu:    echo "<ul>\n";    foreach ($secarray as $section => $url) {        // Echo out a link for this section, highlighting if currently in it        $class = '';        if (strncmp($url, $_SERVER['PHP_SELF'], strlen($url)) == 0) {            $class = ' class="current"';        }        echo "<li{$class}><a href=\"{$url}\">{$section}</a></li>\n";    }    echo "</ul>\n";}    // An array with all section names and the URL to their top directory:$sections = array(    'News' => '/news/',    'Photos' => '/media/pictures/',    'Video' => '/media/movies/',    'Stuff' => '/eliw/'    );// Output a little bit of CSS to accomplish the highlighting:?><style>.current, .current a { color: red }</style><?php// And call the function to test it:create_highlighted_sections($sections);?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?