Ask Phpto call the txt file data and assign the value to the code first page file index.html Reference File:./txt/pan.txt in the third row: the value in the third row of the cursor; how should I write this php? Find a php code that calls txt file data and assigns values
Homepage file index.html
Reference File: The third line in./txt/pan.txt: false or yes
Make an if.elsesentence in index.html. the variable dovalue is the value in the third row of pan.txt;
How should I write this php?
Reference variable reference txt if... else judgment statement share:
------ Solution --------------------
$ MyFile = "./txt/pan.txt ";
$ Lines = file ($ myFile); // put the file into the array
$ Do = $ lines [3]; // line 3
If ($ do = "false "){
Echo "false, do..."; // false
} Elseif ($ do = "yes "){
Echo "yes, do..."; // yes
} Else {
Echo "not supported"; // Other values
}
?>
------ Solution --------------------
Wrong. line 4.
$ MyFile = "./txt/pan.txt ";
$ Lines = file ($ myFile); // put the file into the array
$ Do = $ lines [2]; // line 3
If ($ do = "false "){
Echo "false, do..."; // false
} Elseif ($ do = "yes "){
Echo "yes, do..."; // yes
} Else {
Echo "not supported"; // Other values
}
?>
Reference:
$ MyFile = "./txt/pan.txt ";
$ Lines = file ($ myFile); // put the file into the array
$ Do = $ lines [3]; // line 3
If ($ do = "false "){
Echo "false, do..."; // false
} Elseif ($ do = "yes "){
Echo "yes, do..."; // yes
} Else {
Echo "not supported"; // Other values
}
?>
------ Solution --------------------
What is your template language?
If the knowledge output is correct, you can modify it and directly echo"
"Okay. if it is false, no processing is performed. if it is false, no judgment is required to determine whether it is yes.
Reference:
In fact, the output is
If the do value is yes, it will be output. if it is false, it will not be output. how can this problem be achieved?
{query:name=commend_goods as co join=left join goods as go on co.goods_id eq go.id where=co.commend_id eq 1 and go.is_del eq 0 AND go.id is not null fields=go.list_img,go.sell_price,go.name,go.market_price,go.id limit=7 order=id desc group = id}
{set:$tmpId=$item['id'];}
{$item['name']}
RMB{$item['sell_price']}
{/query}
Quote: reference:
Wrong. line 4.
$ MyFile = "./txt/pan.txt ";
$ Lines = file ($ myFile); // put the file into the array
$ Do = $ lines [2]; // line 3
If ($ do = "false "){
Echo "false, do..."; // false
} Elseif ($ do = "yes "){
Echo "yes, do..."; // yes
} Else {
Echo "not supported"; // Other values
}
?>