Thinkphp's problem has been fixed for a long time. I still don't know. you can take a look.

Source: Internet
Author: User
Thinkphp's problem has been fixed for a long time, but I still don't know. you can take a look at the controller code:
Public function testt (){
// $ Title = "exercise book ";
// $ Content ='
'. $ _ GET ['name'];
// $ This-> assign ('title', $ title );
$ User = M ('name ');
$ List = $ User-> select ();
$ This-> assign ('list', $ list );
$ This-> assign ("title", "SMARTY test ");
$ This-> display ();
}
Code in the template:
{$ Title}



{$ Vo. age} {$ vo. name}

It is important to remove the foreach part, otherwise it will display
Syntax error, unexpected ')', expecting T_VARIABLE or '$ 'd: \ AppServ \ www \ App \ admin \ Runtime \ Cache \ 6e178638460c8ba2282739c247c2ce14. php line 10th.

The code in the cache file is:




$): Echo ($ vo ["age"]); echo ($ vo ["name"]);?>

It seems that I have no clue for a long time. what should I do?


Reply to discussion (solution)

List is empty. check it yourself.

List is empty, and the data can be found in the controller. However, after being handed over to the template, it becomes empty after being processed by the foreach label function. I don't know where the error is ???????????????????????????????????

Public function _ foreach ($ attr, $ content) {static $ _ iterateParseCache = array (); // if it has been parsed, the variable value $ cacheIterateId = md5 ($ attr. $ content); if (isset ($ _ iterateParseCache [$ cacheIterateId]) return $ _ iterateParseCache [$ cacheIterateId]; $ tag = $ this-> parseXmlAttr ($ attr, 'foreach'); $ name = $ tag ['name']; $ item = $ tag ['item']; $ key =! Empty ($ tag ['key'])? $ Tag ['key']: 'key'; $ name = $ this-> autoBuildVar ($ name); $ parseStr ='
 $ '. $ Item.'):?> '; $ ParseStr. = $ this-> tpl-> parse ($ content); $ parseStr. ='
 '; $ _ IterateParseCache [$ cacheIterateId] = $ parseStr; if (! Empty ($ parseStr) {return $ parseStr;} return ;}

I checked the source code for parsing the foreach tag. this is not because the list variable is empty. In fact, the values of name and item in the tag are not obtained, for specific reasons, you can troubleshoot the problem by checking the source code. of course, the simplest solution is to use the volist label instead.

The foreach in your template should be written as {foreach name = ''item =?

Public function _ foreach ($ attr, $ content) {static $ _ iterateParseCache = array (); // if it has been parsed, the variable value $ cacheIterateId = md5 ($ attr. $ content); if (isset ($ _ iterateParseCache [$ cacheIterateId]) return $ _ iterateParseCache [$ cacheIterateId]; $ tag = $ this-> parseXmlAttr ($ attr, 'foreach'); $ name = $ tag ['name']; $ item = $ tag ['item']; $ key =! Empty ($ tag ['key'])? $ Tag ['key']: 'key'; $ name = $ this-> autoBuildVar ($ name); $ parseStr ='
 $ '. $ Item.'):?> '; $ ParseStr. = $ this-> tpl-> parse ($ content); $ parseStr. ='
 '; $ _ IterateParseCache [$ cacheIterateId] = $ parseStr; if (! Empty ($ parseStr) {return $ parseStr;} return ;}

I checked the source code for parsing the foreach tag. this is not because the list variable is empty. In fact, the values of name and item in the tag are not obtained, for specific reasons, you can troubleshoot the problem by checking the source code. of course, the simplest solution is to use the volist label instead.



I have read $ this-> parseXmlAttr ($ attr, 'foreach'). after execution, $ tag has no value ??????????????

What should I do? I write the simplest code,
The result is a problem in the parseXmlAttr function in the source code. But will it be the source code?

What should I do? I write the simplest code,
The result is a problem in the parseXmlAttr function in the source code. But will it be the source code?


Public function parseXmlAttr ($ attr, $ tag) {// XML parsing security filter $ attr = str_replace ('&', '___', $ attr); $ xml ='
 
  
 '; $ Xml = simplexml_load_string ($ xml); if (! $ Xml) {throw_exception (L ('_ XML_TAG_ERROR _'). ':'. $ attr) ;}$ xml = (array) ($ xml-> tag-> attributes (); $ array = array_change_key_case ($ xml ['@ attributes']); if ($ array) {$ attrs = explode (',', $ this-> tags [strtolower ($ tag)] ['attr ']); if (isset ($ this-> tags [strtolower ($ tag)] ['must ']) {$ must = explode (',', $ this-> tags [strtolower ($ tag)] ['must ']);} else {$ must = array ();} foreach ($ attrs as $ name) {if (isset ($ Array [$ name]) {$ array [$ name] = str_replace ('___', '&', $ array [$ name]);} elseif (false! = Array_search ($ name, $ must) {throw_exception (L ('_ PARAM_ERROR _'). ':'. $ name) ;}} return $ array ;}}

Check the source code and print the variables that are unclear. it is easy to find problems. it is not uncommon to make source code errors, the format may be incorrect.


What should I do? I write the simplest code,
The result is a problem in the parseXmlAttr function in the source code. But will it be the source code?


Public function parseXmlAttr ($ attr, $ tag) {// XML parsing security filter $ attr = str_replace ('&', '___', $ attr); $ xml ='
 
  
 '; $ Xml = simplexml_load_string ($ xml); if (! $ Xml) {throw_exception (L ('_ XML_TAG_ERROR _'). ':'. $ attr) ;}$ xml = (array) ($ xml-> tag-> attributes (); $ array = array_change_key_case ($ xml ['@ attributes']); if ($ array) {$ attrs = explode (',', $ this-> tags [strtolower ($ tag)] ['attr ']); if (isset ($ this-> tags [strtolower ($ tag)] ['must ']) {$ must = explode (',', $ this-> tags [strtolower ($ tag)] ['must ']);} else {$ must = array ();} foreach ($ attrs as $ name) {if (isset ($ Array [$ name]) {$ array [$ name] = str_replace ('___', '&', $ array [$ name]);} elseif (false! = Array_search ($ name, $ must) {throw_exception (L ('_ PARAM_ERROR _'). ':'. $ name) ;}} return $ array ;}}

Check the source code and print the variables that are unclear. it is easy to find problems. it is not uncommon to make source code errors, the format may be incorrect.



The array passed to the template in the controller is $ select = array ('id' => 1, 'name' => 'Any ');
In foreach tag processing, this is the sentence in parseXmlAttr ($ attr, $ tag ).
$ Xml = (array) ($ xml-> tag-> attributes (); the resulting $ xml is array (0 ){}
It becomes an empty array after processing, and no data is returned by this function.
This is the step. I made a comparison with your post. The source code is like this. it's pretty good ?????????

Public function _ foreach ($ attr, $ content) {static $ _ iterateParseCache = array (); // if it has been parsed, the variable value $ cacheIterateId = md5 ($ attr. $ content); if (isset ($ _ iterateParseCache [$ cacheIterateId]) return $ _ iterateParseCache [$ cacheIterateId]; $ tag = $ this-> parseXmlAttr ($ attr, 'foreach'); $ name = $ tag ['name']; $ item = $ tag ['item']; $ key =! Empty ($ tag ['key'])? $ Tag ['key']: 'key'; $ name = $ this-> autoBuildVar ($ name); $ parseStr ='
 $ '. $ Item.'):?> '; $ ParseStr. = $ this-> tpl-> parse ($ content); $ parseStr. ='
 '; $ _ IterateParseCache [$ cacheIterateId] = $ parseStr; if (! Empty ($ parseStr) {return $ parseStr;} return ;}

I checked the source code for parsing the foreach tag. this is not because the list variable is empty. In fact, the values of name and item in the tag are not obtained, for specific reasons, you can troubleshoot the problem by checking the source code. of course, the simplest solution is to use the volist label instead.



Volist and foreach have the same effect as.
Tangle, good array, passed to the source code, and then it will be processed as null.

As mentioned above, the values in the list array have not changed, but the php code is not correctly generated when processing the template. I just downloaded a thinkphp, I tried it with the landlord's code and the result is normal. I suggest you go to the thinkphp official website and try the latest version again.

As mentioned above, the values in the list array have not changed, but the php code is not correctly generated when processing the template. I just downloaded a thinkphp, I tried it with the landlord's code and the result is normal. I suggest you go to the thinkphp official website and try the latest version again.



I downloaded 3.1.3 from the official website. Will it be a programming platform Problem? I used EclipsePHP Studio v1.2.2.
The development environment uses the integrated appserv.

After an afternoon, some people on the Internet say that there is a bug, that is, in parseXmlAttr ($ attr, $ tag)
$ Xml = (array) ($ xml-> tag-> attributes ());
Use foreach to traverse $ array. I tried it. in this case, the output array is normal, but the string link in TagLibCx cannot be connected.

A problem occurs in the running environment. Previously, appserv was used for a new one. The problem is solved. However, there was no problem with the previous use.
Why is there a problem with thinkphp labels ???????

Php environment is better than php3.0

A problem occurs in the running environment. Previously, appserv was used for a new one. The problem is solved. However, there was no problem with the previous use.
Why is there a problem with thinkphp labels ???????


Is your problem solved? Must I change the environment ?, My ThinkPHP version is 3.1.3 and php version is php6. Should I change this?

Solved it. PHP6 won't work. I changed it to PHP5, and then I can.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.