Blogger Information
Blog 7
fans 0
comment 0
visits 2348
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP 作用域---文件模块化引用---- 内容动态循环输出
东风又西风
Original
259 people have browsed it
  1. <?php
  2. $num1=100;
  3. $num2=200;
  4. //num1,num2为普通变量 有作用域局限
  5. const NUM3=500;
  6. //用const 声明的为常量,为全局作用域.声明常量时习惯用大写
  7. //普通变量引入函数方法为global
  8. function global1(){
  9. global $num1,$num2;
  10. }
  11. //或者可以用$globals函数提升普通变量为全局作用域变量
  12. function global2(){
  13. ($GLOBALS['one'] + $GLOBALS['two']);
  14. }
  1. define('DAY', '/0410');
  2. // echo DAY;
  3. define('DS', DIRECTORY_SEPARATOR);
  4. define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . DAY . '/web1');
  5. // echo ROOT_PATH;
  6. // 数据路径
  7. define('DATA_PATH', ROOT_PATH . '/data');
  8. // 模板路径
  9. define('TMPL_PATH', ROOT_PATH . '/template');
  10. // 公共模板路径
  11. define('TMPL_PATH_PUBLIC', TMPL_PATH . '/public');
  12. // 静态资源路径
  13. define('STATIC_PATH', ROOT_PATH . '/static');
  14. define('STATIC_CSS_PATH', STATIC_PATH . '/css');
  15. define('STATIC_JS_PATH', STATIC_PATH . '/js');
  16. define('STATIC_IMG_PATH', STATIC_PATH . '/images');

定义DATA_PATH 如果是动态的日期的话,第二天就无法使用了!!

  1. <div class="list">
  2. <?php foreach ($news as $k => $v) : extract($v) ?>
  3. <a href="<?= $url ?>"><?= mb_substr($title, 0, 16) ?>...</a>
  4. <?php endforeach ?>

news页面内容循环输出

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!