New users ask PHP experts to correct code errors, a simple BLOG Code.

Source: Internet
Author: User
I just got in touch with PHP. Now I have learned a simple blog from "no basic learning PHP" compiled by Chen Hao. After I typed the code, I found that an error occurred during execution, when I enter the title and content for submission, click to view the log page to display "request parameter error", but I do not know where the problem is. And for the following...

I just got in touch with PHP. Now I have learned a simple blog from "no basic learning PHP" compiled by Chen Hao. After I typed the code, I found that an error occurred during execution, when I enter the title and content for submission, click to view the log page to display "request parameter error", but I do not know where the problem is. If you do not understand the following code, please answer them together:

  1. What is the role of $ OK in add. php5? The lines of code it appears are not very understandable.

  2. Why is the code in if (mkdir ($ folder) And If (strlen ($ result)> 0) use a double slash? It seems that it is not used for annotation.

  3. A href = "post. php5? Entry = '. $ entry.' "This line of code does not understand why there are periods before and after $ entry. I hope to explain this line to me.

The related code has been attached. I am a cainiao with the help of a friend who wishes to understand it. I am very grateful.

Add. php5


  An error occurred while creating the directory. An error occurred while adding the log.

';}}$ Fp = @ fopen ($ file_name, 'w'); if ($ fp) {flock ($ fp, LOCK_EX); $ result = fwrite ($ fp, $ blog_str); $ lock = flock ($ fp, LOCK_UN); fclose ($ fp);} if (strlen ($ result)> 0) {// $ OK = false; $ msg = 'Log added successfully, view this log topic '; echo $ msg ;}}?> Simple text-based BLOG

My BLOG

----- I have dream...

Add a new log

About me

I am a PHP enthusiast

CopyRight 2011

Style.css

body{    font-size:12px;    background-color:#c6c68c;    padding:0;    font-family:Helvetica,sans-serif;}#container{    margin-left:auto;    margin-right:auto;    margin-top:2px;    margin-bottom:0;    padding:0;    width:760px;    background-color:#f6f6f6;    border:1px solid #000;}#header{    margin-left:auto;    margin-right:auto;    padding:8px;    height:80px;    background-color:#E8F3FD;    border-bottom:1px solid #000;    font-size:16px;    font-weight:bold;}#title{    margin-left:auto;    margin-right:auto;    padding:8px;    height:10px;    background-color:#E8F3FD;    border-bottom:1px solid #000;    font-style:italic;}#left{    float:left;    margin:6px 0 4px 2px;    padding:5px;    width:530px;}#right{    float:right;    margin:6px 0 4px 2px;    padding:5px;    width:200px;}#blog_entry{    margin-left:auto;    margin-right:auto;    margin-top:4px;    margin-bottom:10px;    border:1px solid #000;    background-color:#fff;}#blog_title{    border-bottom:1px solid #000;    background-color:#e8ecdb;    margin:0px;    padding:4px;    font-weight:bold;    font-size:13px;}#blog_body{    margin-left:auto;    margin-right:auto;    padding:0 0 8px 0;    font-size:10px;}#blog_date{    margin-left:auto;    margin-right:auto;    padding:0 0 8px 0;    font-size:10px;}#sidebar{    margin-left:auto;    margin-right:auto;    border:1px solid #000;    width:180px;    background-color:#fff;}#menu_title{    border-bottom:1px solid #000;    background-color:#e8ecdb;    margin:0px;    padding:4px;    height:10px;    font-weight:bold;}#menu_body{    margin-left:auto;    margin-right:auto;    margin-top:4px;    padding:6px;}#footer{    clear:both;    text-align:center;    margin-left:auto;    margin-right:auto;    padding:8px;    height:10px;    background-color:#e8f3fd;    border-top:1px solid #000;}#err{    color:red;}

Post. php5


  Log title:'. $ Content_array [0]; echo'
Release date:'. Date ('Y-m-d H: I: s', $ content_array [1]); echo ""; echo $ content_array [2];?>

Reply content:

I just got in touch with PHP. Now I have learned a simple blog from "no basic learning PHP" compiled by Chen Hao. After I typed the code, I found that an error occurred during execution, when I enter the title and content for submission, click to view the log page to display "request parameter error", but I do not know where the problem is. If you do not understand the following code, please answer them together:

  1. What is the role of $ OK in add. php5? The lines of code it appears are not very understandable.

  2. Why is the code in if (mkdir ($ folder) And If (strlen ($ result)> 0) use a double slash? It seems that it is not used for annotation.

  3. A href = "post. php5? Entry = '. $ entry.' "This line of code does not understand why there are periods before and after $ entry. I hope to explain this line to me.

The related code has been attached. I am a cainiao with the help of a friend who wishes to understand it. I am very grateful.

Add. php5


  An error occurred while creating the directory. An error occurred while adding the log.

';}}$ Fp = @ fopen ($ file_name, 'w'); if ($ fp) {flock ($ fp, LOCK_EX); $ result = fwrite ($ fp, $ blog_str); $ lock = flock ($ fp, LOCK_UN); fclose ($ fp);} if (strlen ($ result)> 0) {// $ OK = false; $ msg = 'Log added successfully, view this log topic '; echo $ msg ;}}?> Simple text-based BLOG

My BLOG

----- I have dream...

Add a new log

About me

I am a PHP enthusiast

CopyRight 2011

Style.css

body{    font-size:12px;    background-color:#c6c68c;    padding:0;    font-family:Helvetica,sans-serif;}#container{    margin-left:auto;    margin-right:auto;    margin-top:2px;    margin-bottom:0;    padding:0;    width:760px;    background-color:#f6f6f6;    border:1px solid #000;}#header{    margin-left:auto;    margin-right:auto;    padding:8px;    height:80px;    background-color:#E8F3FD;    border-bottom:1px solid #000;    font-size:16px;    font-weight:bold;}#title{    margin-left:auto;    margin-right:auto;    padding:8px;    height:10px;    background-color:#E8F3FD;    border-bottom:1px solid #000;    font-style:italic;}#left{    float:left;    margin:6px 0 4px 2px;    padding:5px;    width:530px;}#right{    float:right;    margin:6px 0 4px 2px;    padding:5px;    width:200px;}#blog_entry{    margin-left:auto;    margin-right:auto;    margin-top:4px;    margin-bottom:10px;    border:1px solid #000;    background-color:#fff;}#blog_title{    border-bottom:1px solid #000;    background-color:#e8ecdb;    margin:0px;    padding:4px;    font-weight:bold;    font-size:13px;}#blog_body{    margin-left:auto;    margin-right:auto;    padding:0 0 8px 0;    font-size:10px;}#blog_date{    margin-left:auto;    margin-right:auto;    padding:0 0 8px 0;    font-size:10px;}#sidebar{    margin-left:auto;    margin-right:auto;    border:1px solid #000;    width:180px;    background-color:#fff;}#menu_title{    border-bottom:1px solid #000;    background-color:#e8ecdb;    margin:0px;    padding:4px;    height:10px;    font-weight:bold;}#menu_body{    margin-left:auto;    margin-right:auto;    margin-top:4px;    padding:6px;}#footer{    clear:both;    text-align:center;    margin-left:auto;    margin-right:auto;    padding:8px;    height:10px;    background-color:#e8f3fd;    border-top:1px solid #000;}#err{    color:red;}

Post. php5


  Log title:'. $ Content_array [0]; echo'
Release date:'. Date ('Y-m-d H: I: s', $ content_array [1]); echo ""; echo $ content_array [2];?>

What books did you read? Can I photograph the code in your book?

Answer your question by the way:

  1. That$okThe variable does not seem to be useful at the moment. It may be used to record whether an error occurs during code execution and assign itfalseAccording to its value, it is displayed as successful or failed to add.

  2. Added//That is, the line of code will not be executed.

  3. In PHP.Is used to connect strings. In your code, it is used to spell HTML code.
    Example:


  

As for the error you mentioned at the beginning, I think the reason may be that you did not take it seriously when you typed the code._Underline.
See:

Compare the entered code with the code in your book.

The landlord is a sister.

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.