public static function read ($file) {
Str_replace (', ', ', ', $file);
$tmp = Explode (', ', $file);
foreach ($tmp as $v) {
$tmp _file = Base_path. ' /language/'. Lang_type. DS. $v. ' PHP ';
if (file_exists ($tmp _file)) {
Require ($tmp _file);
if (!empty ($lang) && Is_array ($lang)) {
Self:: $language _content = Array_merge (self:: $language _content, $lang);
}
Unset ($lang);
}
}
return true;
}
The writing in the above Code str_replace (', ', ', ', $file), what is the purpose of it, does it not feel the effect of it, is it to prevent what?
Reply to discussion (solution)
Here is an extra sentence, because the result of str_replace substitution is not copied to $file
This sentence is to replace the Chinese comma with a comma, but this is not directly written, to assign value to $file
public static function read ($file) {
$file = Str_replace (', ', ', ', $file); Change the Chinese comma to English
$tmp = Explode (', ', $file);//use commas to divide the names into groups
foreach ($tmp as $v) {//loop array
$tmp _file = Base_path. ' /language/'. Lang_type. DS. $v. php;//Find a file based on the key value of the array
if (file_exists ($tmp _file)) {//If the file exists
Require ($tmp _file);//Return file
if (!empty ($lang) && Is_array ($lang)) {//If $lang is not empty and is a number of arrays
Self:: $language _content = Array_merge (self:: $language _content, $lang);
}
Unset ($lang);//Delete $lang
}
}
Return true;//Returns True
}
The full-width "," replaced by ",", conjecture may be used for example, when the tag, prompting the user more than one label can be separated, but some users input the time to write the full-width, so the full-width of the replacement.
This sentence is to replace the Chinese comma with a comma, but this is not directly written, to assign value to $file
public static function read ($file) {
$file = Str_replace (', ', ', ', $file); Change the Chinese comma to English
$tmp = Explode (', ', $file);//use commas to divide the names into groups
foreach ($tmp as $v) {//loop array
$tmp _file = Base_path. ' /language/'. Lang_type. DS. $v. php;//Find a file based on the key value of the array
if (file_exists ($tmp _file)) {//If the file exists
Require ($tmp _file);//Return file
if (!empty ($lang) && Is_array ($lang)) {//If $lang is not empty and is a number of arrays
Self:: $language _content = Array_merge (self:: $language _content, $lang);
}
Unset ($lang);//Delete $lang
}
}
Return true;//Returns True
}
Again, the final result of this method is to return true;
My question is, what's the use of this function, because it finally returns a true, does it mean anything?
Who says it's useless, does it not have the following statement, which merges the static variable $language _content of the class one at a time when the condition is met.
if (!empty ($lang) && Is_array ($lang)) {
Self:: $language _content = Array_merge (self:: $language _content, $lang);
}
Return true is only the return value when the condition is not satisfied.
Who says it's useless, does it not have the following statement, which merges the static variable $language _content of the class one at a time when the condition is met.
if (!empty ($lang) && Is_array ($lang)) {
Self:: $language _content = Array_merge (self:: $language _content, $lang);
}
Return true is only the return value when the condition is not satisfied.
It should be the return value when the condition is met.
Oh, that's wrong. Whether or not into if will be executed return true, in fact, return true here is not much use, you just look at my red that paragraph is enough.
The main point is require ($tmp _file);
Bulk loader Program Files