You can switch back and forth between PHP and HTML in the same document, and you can use the same software—any plain text editor will do—to write PHP as to write HTML
How to Add Links to PHP Documents
If you are making a link in a PHP document that is outside of the PHP brackets, you just use HTML as usual. Here is an example:
<a href="https://twitter.com/marshallunduemi">My Twitter</a> <?php ----- My PHP Code---- ?>
If the link needs to be inside the PHP, you have two options. One option is to end the PHP, enter the link in HTML, and then reopen PHP. Here is an example:
<?php ----- My PHP Code---- ?> <a href="https://twitter.com/marshallunduemi">My Twitter</a> <?php ----- My PHP Code---- ?>
The other option is to print or echo the HTML code inside the PHP. Here is an example:
<?php echo "<a href=https://twitter.com/marshallunduemi>My Twitter</a>" ?>
Another thing you can do is create a link from a variable. Let's say that the variable $url holds the URL for a website that someone has submitted or that you have pulled from a database. You can use the variable in your HTML.
<a href="https://twitter.com/marshallunduemi">My Twitter</a> <?php $site_title="My Website"; $url="http://codexpresslab.blogspot.com/"; echo "<a href='$url'>$site_title</a>" ?>
For Beginning PHP Programmers
If you are new to PHP, remember you begin and end a section of PHP code using respectively. This code lets the server know that what is included is PHP code. Try a PHP beginner's tutorial to get your feet wet in the programming language. Before long, you'll be using PHP to set up a member login, redirect a visitor to another page, add a survey to your website, create a calendar, and add other interactive features to your webpages.
Bradley, Angela. "How to Create Links in PHP." ThoughtCo, Jul. 5, 2018, thoughtco.com/create-links-in-php-2693950.
Hit me with a comment!