Details about pointer instances-php Tutorial

Source: Internet
Author: User
1. received url content publicfunctionnewstype (Request $ request) {$ url $ request-& gt; url (); $ isfirstinput (isfirst); $ uidinput (token);} 2. pointer instance. & amp;
// 1. receive the content in the url

 public function newstype(Request $request)    {        $url = $request->url();        $isfirst = input('isfirst');        $uid = input('token');   }

 

A. replace nowtime in $ news with $ mm ....

$ News = Db: query ('select news. nid, news. ntitle, news. nauthor, news. reviewnum, news. nowtime, news. iscollect, newreview. ncommtent from news, newreview WHERE news. nid = newreview. nid'); foreach ($ news as & $ mm) {// news comment $ ncommtent = Db :: query ("select ncommtent from newreview where nid = {$ mm ['nid']}"); foreach ($ ncommtent as $ vvv) {$ mm ['ncommtent'] = "{$ vvv ['ncommtent']}" ;}$ nowtime = Db: query ('select nowtime from new '); foreach ($ nowtime as $ n) {$ mm ['nowtime'] = date ("Y-m-d H: I: s ", $ n ['nowtime']);}

  

B. append $ vvv ['ncommtent] to $ new.

$ News = Db: query ("select nid, ntitle, nauthor, reviewnum, nowtime, iscollect from news where nsid = '{$ ntid}' limit 6 "); foreach ($ news as & $ mm2) {// news comment $ ncommtent = Db :: query ("select ncommtent from newreview where nid = {$ mm2 ['nid']}"); foreach ($ ncommtent as $ vvv) {$ mm2 ['ncommtent'] = "{$ vvv ['ncommtent']}";}

// 3. output json

$ Data = array ('code' => 0, 'MSG '=> array ('news' => $ news, 'newsimg' => $ newsimg, 'Comments '=> $ comments); return json_encode ($ data, 256); // Convert json with no garbled characters

  

The above is a detailed description of the pointer instance. For more information, see other related articles in the first PHP community!

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.