Placeholder Image

字幕列表 影片播放

  • So let's talk about using the print function in PHP to create Web pages that are formatted for HTML.

  • As we've talked about before.

  • It's important.

  • Understand that when you use the print function that you're printing out essentially to a text file.

  • So if you don't add in the formatting tags for HTML, then when somebody goes to to look at the Web page that's been created, the formatting won't be there, and it will probably look very odd.

  • So whenever you're going to be using the print function and the person that's going to be consuming, whatever the content is created is going to be using a Web browser.

  • T view the content that you add the HTML tags in.

  • So what's with that?

  • Let's go over to the computer so I can show you how to add the HTML tags in for when you're using the print function of PHP.

  • So this is a very simple script and PHP to create an unordinary list using the print function.

  • I also have a second script that uses the new line command within the print function.

  • So this will.

  • What will this will show you is both how you can use HTML in order to four Matt texts so that it could be looked at through a Web browser and how you could do things such as use the new line command so that you can format the source for the Web page so that it's easier to look at all you have to dio again.

  • This is very simple.

  • What you have to be thinking about using the print function is all all the print function really does is it's automatically writing HTML code for you.

  • So essentially what you do with print function is you write the HTML code and then you just ad print before that so that Ph.

  • B.

  • Will print out that HTML code for you.

  • So with here again, we start with simple Web page.

  • We have.

  • We have the H one tag, basically a title for the top, says PHP.

  • Print example.

  • We then called PHP with PHP tag, and then the first thing that we're going to do is we're going to print double quotation marks and then we're going to use the A nordeste tag.

  • So you Ellis for a kn ordered list.

  • We close with double quotations and then we end the line with a semicolons, you're always gonna have to remember that semicolon.

  • We're just going to print again, again, double quotations.

  • And then we're going to have the first list item in the UN order list.

  • So we do.

  • L I and they're going to say print item one, and then we're going to close the list item.

  • So this will give us a bullet point for this particular item.

  • Then we do double quotation marks and then we do semi colon and the line.

  • We just continue to do that two more times.

  • So again, list item close list item list, item closed list item.

  • And what we do finally is we're going to do print double quotation marks and then we're going to close theon ordered list.

  • So we're going to close the U L tag again double quotation marks and semi colon.

  • So what this is doing is this is just simply printing out all of this html code onto the web page, and then you're going to be able to view this through the Web browser, and then finally, we're going to close the PHP script.

  • Then we're going to show you a different script down here.

  • This simply ads in the new line command, so PHP print with a new line example.

  • It's the exact same code as up here.

  • The only difference is at the end of each of these lines, it's going to a new line command, and so is going to write it in text as a new line.

  • Now, if you want to see what the difference is, if we pull up the Web page, what we can take a look at is this is the example.

  • So this is the first example.

  • PHP print example Print item one print item to print item three.

  • So what we did is we had PHP actually print out that HTML code.

  • Now, if you look at the the new line command example, it looks exactly the same, and from a Web browser perspective, it is exactly the same.

  • Where the difference is is if we go and we we take a look at the source code for this particular page.

  • What we can see is when we simply use the new line function, it wrote everything out on a single line.

  • So this is where we open the UN order list, and then we have the first item that way.

  • The second item that we have the third item and then we close Ian ordered list.

  • So so the Web browser can read this creek, take those HTML tags and then format this in HTML.

  • The problem is, is, as you can see, this is very simple.

  • This is three items in an unordinary list, and if everything is simply printed out on one line, it can get very confusing to look at very quickly.

  • If you're trying to troubleshoot the code again, remember when you start adding functions and when we start connecting the databases when we start doing, ah, lot of cool, fancy things.

  • If everything is just in one block and there's a problem, it can be difficult to figure out what the problem is.

  • Well, if you use the new line command, if you form at the text that you're printing out, then it makes it easier to go through a troubleshoot and see what's going on.

  • So when we do the H one you know, print with the new line example here, what we can see is you l was printed on one line than The first item was printed on one line that the second item was printed on the next line.

  • The third item was printed on the next line, and then the UL closes.

  • So this is very easy to take a look at for the source code and see what's going on with the Web page, even though it does exactly what this does.

  • The main point here is it's easier for a technician.

  • It's easier for a fellow programmer to see what's happening.

  • So if they need to modify things in the future, or if they need to figure out what's going on with your code, it makes life a lot easier.

  • So that's really all there is to writing an HTML page with PHP.

  • Essentially, all you do is use the print command with all the HTML tags, as you normally would.

  • Well, you have to be really thinking about with whether or not use the new line command or not is, do you think you're gonna go back and ever have to take a look at the source for the Web page to see if there's any problems or any issues.

  • So that's all there is with the printing HTML formatting with the print function in PHP again, as I've thought about before, PHP is essentially the secretary for the Web world.

  • It sends information to databases or files, pulls information from databases or files, and then you have to tell it how you want things to be formatted.

  • Do you want things before mattered for a simple text file?

  • Or do you want things before mattered for a Web page?

  • If you want them to be formatted for a Web page, all you have to d'oh is go in and you have to tell it things like what tags to use with CSS to use Ah, whole bunch of other stuff.

  • But the important thing to understand is, really you just use print double quotation marks and then everything past that is essentially the normal HTML or CSS or Java script or whatever code that you would normally right.

  • You can copy your paste, or you can write it out.

  • And then what will happen is when PHP is called, it will use the print function.

  • It will then print that the Web browser will then interpret what's been printed, and then the Web page will show up with whatever format, and if you want to be a tch one, if you want to be, too.

  • If you wanted to be on multiple sentences or paragraphs or whatever, that's all done with the HTML code.

  • So that's really all there is to formatting on HTML page with pH.

  • Peas.

  • Print a function and that's why it matters.

So let's talk about using the print function in PHP to create Web pages that are formatted for HTML.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

PHP--打印HTML網頁,有了它,你就能輕鬆地打印出自己的網頁。 (PHP - Print HTML Web Pages with...)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字