An If statement in PHP is always poorly written.

Source: Internet
Author: User
Tags parse error
Before this is read the database code, omitted here ...
And then here, it's not going to happen.


  
   找人起个名字吧!
  
   这个名字还不错么
  
   

Problem one: The first line writes the following error:

PHP Parse error:syntax error, unexpected ' $row ' (t_variable), expecting ' (' in I:\php\index.php on line 119

The other lines have nothing wrong temporarily unknown

Question two: There is no quick way to write, that is, all by PHP, rather than with the HTML mixed together, it seems that the execution efficiency will be very poor.

Well, I admit that this is from the ASP, just learn PHP, do not know where to check these problems.

Reply content:

Before this is read the database code, omitted here ...
And then here, it's not going to happen.


  
   找人起个名字吧!
  
   这个名字还不错么
  
   

Problem one: The first line writes the following error:

PHP Parse error:syntax error, unexpected ' $row ' (t_variable), expecting ' (' in I:\php\index.php on line 119

The other lines have nothing wrong temporarily unknown

Question two: There is no quick way to write, that is, all by PHP, rather than with the HTML mixed together, it seems that the execution efficiency will be very poor.

Well, I admit that this is from the ASP, just learn PHP, do not know where to check these problems.

else missed a colon
No spaces in endif

If the last semicolon is changed to a colon, then add a semicolon after the endif.

The conditions after the if are wrapped in parentheses.


  
   找人起个名字吧!
  
   这个名字还不错么
  
   

The condition after the if is enclosed in parentheses, $row [' name], where there is a single quote missing, and else to change to else:,end if to endif;

$row['name]=""Here's name a short ' quote, and this judgment should not be two equals sign?

PHP to do web development mixed is inevitable. You can also use a template engine, but now you have to understand the mixed.

Master, how do I feel that you are using the CI framework.

The quick way of writing is the template engine, most of which are now in the framework. Like Laravel's blade.

@if($row['name]="" or is_null($row['name']))找人起个名字吧!@else这个名字还不错么@endif
  • Related Article

    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.