PHP and HTML code

Source: Internet
Author: User
Tags html tags php and
PHP is not simply a random output of values and simple text. You can seamlessly integrate PHP and HTML and output tables, formatted text, and so on. You probably don't know, what's the big deal? The deal is that you can control what is displayed on your site by consolidating PHP and HTML. Most importantly, PHP does not have its own set of formatting tags for you to learn. You use HTML.

So, let's get started. First, copy and paste the following code into a PHP page:

<body>
“ ? The PHP
Print ("Can the real Gopher team dash into the code php?") ” ) ;
? “
"/Weight"
"/html"
When you preview the Web page containing the above content of the code, you should see the text "Can you really dig the mouse team into the code PHP?" "Text format is not all. You will see the text displayed for the default font set to your browser.

You don't have to suffer through dull but boring text. You can format-all of the P HP label fields. For example, to bold words. Add markup bold, <b> and "</b" tagged text:

“ ? The PHP
Print ("<b> can the real burrowing rat team rush into the code php?" "/b" ");
? “
When you modify the code, your PHP tags with your bold tags (see above code) and preview the page in your browser, you will find that the text is now bold. Pretty cool, ehh? Now, let's try adding a horizontal line below the text. HTML tags show a horizontal line is
Let us add that our tag number:

“ ? The PHP
Print ("<b> can the real burrowing rat team rush into the code php?" "/b" ");
Print ("? “
Now, test this code. You should now be able to see your text with the horizontal line display. Just keep in mind that we are using the Print command for standard HTML tags.

Output data, involving quotes
While all this is very simple, you will not be able to perform a series of HTML tags within the restricted print command. Here is an example

Let's say we want our text to be super connected. Doing this trick in HTML is:

<a href= "http://www.kirupa.com/" > can the Real burrowing mouse team rush into the code PHP? "/1"

Now, we can't simply put the print command inside the HTML above. The reason is because of the fear of quotes around the URLs. PHP's distorted quotes refer to the end Print command. You may end up with an error.

The solution prints quotation marks by using the following two characters (quotes and back slashes) in the position of the quotes: ". Therefore, the HTML code for the Print command becomes:

“ ? The PHP
Print ("The <a href=" http://www.kirupa.com/"> can the Real burrowing mouse team rush into the code PHP? "/1" ");
? “
The place I want to emphasize is the "change to" coloring of these characters in pink. Whenever you see a quote, just add one at the front (or replace the quotes with "). I know my repetition, again and again, but this is a small detail that you may end up forgetting in the heat of coding!

Quick overview
Review time! You can use HTML tags in PHP to use the print tags and normal, everyday HTML.
All you do is use exactly the same HTML tags you will normally use for HTML files, but the difference is that you will be between these tags in print ("and"); When you deviate from this format is when your HTML contains quotes.

When you encounter the quote, replace your quote with the following two features: "



For example more participation in
The following code fragment is an example of PHP and HTML used together. Hopefully it provides some insight into PHP and HTML that can be used together to show some tables, graphics and formatted text:

“ ? The PHP
Print ("<font size=" 2 "face=" Arial ">");
Print ("<table style=" Border-collapse:collapse "width=" "border=" 2 ">");
Print ("<tr> <td width=" 2% "bgcolor=" #b7d0e3 "> <font size=" 2 ">");
Print ("
"/font" "/Transport Department");
Print ("<td width=" 98% "bgcolor=" #eaf1f7 "> <font size=" 2 "> <b> quick Summary"/b ");
Print (""/font ""/Transport Department ""/Wen "<tr> <td widt" 100% "colspan=" 2 ">);
Print ("<table bordercolor=" #111111 "cellpadding=" "border=" 0 ">");
Print ("<tr> <td width=" 100% ">"/Font "<font size=" 2 "face=" Arial "> Complex
For example, tables and pictures are involved. "/font" "/Transport Department");
Print (""/Wen ""/table ""/Transport Department ""/Wen ""/table ");
? “
The above example does not use any new things, but it still involves a lot of backslashing.
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.