Connecting php knowledge with html


#1

Hey guys, I have finished a html, css and php lessons and I need someone to help me with these two(to be more precise three). The problem is that I don’t know how to use a php knowledge inside html, i would be thankful if someone could sent me some tutorials about that or just to write simple notes.


#2

We build dynamic websites by doing server-side processing and interacting with a database. Then we insert that content into the HTML before it’s sent out the browser for you to view.

For example, let’s say you are viewing this article on the Codecademy’s blog. Open up Developer Tools in your browser (Chrome or Firefox) and inspect the HTML elements. You’ll notice this:

<header>
     <a href="/blog/announcing-codecademy-pro">
        <h2>Get Resume-Ready Skills to Advance Your Career with the New Codecademy Pro Suite</h2>
     </a>
</header>

For this blog post, it’s URL, title, and content reside in a database back on the server. Let’s say the website is using PHP as the server-side language.

How would you embed the URL and title for this post into the HTML? Let’s assume the variables are named $post_url and $post_title to keep it simple.

<header>
     <a href="<?php echo $post_url; ?>">
        <h2><?php echo $post_title; ?></h2>
     </a>
</header>

Notice how you are inserting PHP directly into the HTML.

How does the server know it’s PHP? You told it with the opening PHP tag (<?php) and closing PHP tag (?>). The server then runs the code that’s between those tags.

Does that help you?


#3

Well yes, but this is something simple, I don’t know what to write (build) in php with knowledge from php unit and insert it. Can you give me example of finished php material inserted in html?
Thank you very much for the quick feedback !


#4

Head over to GitHub and do a search for PHP projects. You will find thousands of them.

For example:

  • [Edited: personal website link disallowed in forums. Refer to user profile.]
  • Here’s Laravel, a PHP Framework

Cheers,
Tonya