While. How to assign a value to one variable. -Php Tutorial

Source: Internet
Author: User
While. How to assign a value to one variable. While. How to assign a value to one variable.

Echo"
    ";
    While ($ rs = $ result-> fetch_assoc ()){
    Echo"
  • ". $ Rs ['name']."
  • "; // Loop body, loop all articles
    }
    Echo"
"




Reply to discussion (solution)

$ S = '';
While ($ rs = $ result-> fetch_assoc ()){
$ S. ="

  • ". $ Rs ['name']."
  • "; // Loop body, loop all articles
    }
    Echo $ s;

    Yes. Xuzuning is strange to me. It is actually a variable value.

    I assigned this value to a str_ireplace


    $ S = str_ireplace ("<{aaa}>", $ aaa, $ str); // replace content


    Then
    Fopen ("/muban/muluye.html", "r") // The template is read normally.
    $ A = fopen ($ shengchenglujin, 'w'); // set the path and print it out. the path can be read and written.
    Fwrite ($ a, $ s); // you cannot write it here.

    It's strange. what's going on?

    Yes. Xuzuning is strange to me. It is actually a variable value.

    I assigned this value to a str_ireplace


    $ S = str_ireplace ("<{aaa}>", $ aaa, $ str); // replace content


    ..

    You echo $ s; what are there?

    $ S = '';
    While ($ rs = $ result-> fetch_assoc ()){
    $ S. ="

  • ". $ Rs ['name']."
  • "; // Loop body, loop all articles
    }
    Echo $ s;

    Use is_writable to view and write the result.

    You echo $ s; what are there?

    Can be displayed normally.
    I add $ s = "1111" before fwrite ($ a, $ s); and it can be written normally, such as referencing the result of while. Cannot be written.

    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.