简体   繁体   English

以正确的方式包含 php 文件

[英]Include php files the correct way

/* index.php */
require_once('region.php');
require_once('es.php');
  • index.php includes region.php -region-related info (also sets $regionLang = 'es'; ) and es.php -mostly Spanish translations. index.php 包括region.php - 区域相关信息(也设置$regionLang = 'es'; )和es.php - 主要是西班牙语翻译。 Second file needed if language is Spanish 'es' or it would be a different file eg 'en-us.php'如果语言是西班牙语'es' ,则需要第二个文件,否则它将是不同的文件,例如'en-us.php'
  • would you include es.php inside region.php and why?你会region.php包含es.php吗?为什么? Also how?又如何?
    • region.php is essential, es.php is important but scripts will run withot translations region.php 是必不可少的,es.php 很重要,但脚本将在没有翻译的情况下运行
    • whatever language is used in region.php, the corresponding translation file will be required无论 region.php 使用什么语言,都需要对应的翻译文件
    • require() or include() in case of es.php ?es.php的情况下 require() 或 include() ?
/* index.php */
require_once('region.php');
/* region.php */
require_once('es.php');

I would include es.php into region.php我会将 es.php 包含到 region.php

Because, region.php decide my language whether it is spanish or not.因为,region.php 决定我的语言是否是西班牙语。 If it is not my language, i can change the language file如果不是我的语言,我可以更改语言文件

We suppose in region.php;我们假设在 region.php;

//region.php    
    if(myRegion()=="Turkey"){
      require_once('turkish.php');
    }else if(myRegion()=="Spania"){
      require_once('es.php');
    }

so we avoid unnecessary file loads所以我们避免了不必要的文件加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM