By visiting our site, you agree to our privacy policy regarding cookies, tracking statistics, etc.

proper noun logo blue
  • Content Marketing
    • SEO Articles
    • Pillar Content
    • Website Content
    • Content Briefs
  • Off-Page
    • Managed Outreach
  • Optimization
    • Content Optimization
    • Technical SEO
  • Verticals
    • Ecommerce SEO Services
    • SaaS SEO Services
    • Enterprise Business SEO
    • Local SEO Services
  • Case Studies
  • Support
The Roadmap
Book A Demo
Simplify Your Coding By Using Some Simple PHP
December 8, 2019by adamUncategorized

Simplify Your Coding By Using Some Simple PHP

PHP is a server side language that is used for web development and can be easily inserted into and used with HTML. PHP has a wide variety of uses and applications, but today I’m going to talk about the include statement. By using a PHP include statement you can save yourself a ton of time and keep your code much cleaner. For this example, I’ll use the statement for my navigation.

First things first, you’ll need to fully code out the html and css of at least one page on your website. If you’ve saved your file as “index.html” create a new copy by clicking “Save As” and saving as “index.php” so that your PHP will be able to execute. Once you’ve done this, locate the section of your code with your navigation in it. Here’s what my code looks like:

<div>
    <ul>
        <li>Link 1</li>
        <li>Link 2</li>
        <li>Link 3</li>
        <li>Link 4</li>
        <li>Link 5</li>
        <li>Link 6</li>
    </ul>
</div>

There is corresponding CSS, as there should be with yours as well, but it is not important for the purposes of this post so I’m not including it to keep this easier.
Next you will create a new file called “navigation.php” and save it in your directory. We are going to use this file to control the navigation throughout the entire site.

Once you’ve saved the new navigation.php file, go back to your index.php file and copy all of the code for your navigation that is inside the class “navigation” and then paste it inside of navigation.php and save. It should look like this:

<ul>
        <li>Link 1</li>
        <li>Link 2</li>
        <li>Link 3</li>
        <li>Link 4</li>
        <li>Link 5</li>
        <li>Link 6</li>
</ul>

Now, back in your index.php file, replace the text you just copied inside the class “navigation” with the following and save:

<?php include 'navigation.php'; ?>

If done correctly, when you preview your page either online or on your test server, the PHP include statement should pull the unordered list inside of “navigation.php” into the class “navigation” and apply it’s styling.

Now, if and when you need to make changes to your navigation, links, pages, etc., you’ll only have to change one file, one time, not multiple times on multiple pages. This same method can be applied to several aspects of your site. For instance, your entire header area, including your logo, navigation, and so on can be in a file called “header.php” which can be called in all of your pages. This way, if you change your logo down the line, you can instantly change it site wide just by changing one file.

This is just a sample of what PHP can do in improving your sites functionality and usability. For more information on PHP and the many functions it can perform just check out the PHP Website.

Read More
Share
proper noun logo blue

Proper Noun is an SEO, digital growth, and content marketing agency located in Fort Lauderdale, FL.

Twitter Facebook-f Google-plus-g Pinterest-p Linkedin-in

Contacts

Our Offices
300 SW 1st Ave #155
Fort Lauderdale, FL 33301
Give Us A Call
(954)674-1258

Our Services

  • Content Marketing
  • Ecommerce SEO Services
  • Enterprise Business SEO
  • Managed Outreach
  • Technical SEO
  • Website Optimization

Our Company

  • Blog
  • Contact Us
  • Book A Demo
  • Case Studies
  • Article Writing
  • Website Directory

© 2022 Proper Noun. All Rights Reserved.

Proper Noun is a content marketing agency located in Fort Lauderdale, FL. Proper Noun provides managed content marketing campaigns and managed outreach campaigns for ecommerce businesses, saas products, law firms, real estate, enterprise businesses and much more. We also offer a la carte content creation services.

Markets We Serve

  • Ecommerce SEO
  • Enterprise SEO
  • International SEO
  • National SEO
  • Local SEO
  • B2B SEO
  • Whitelabel SEO
  • SEO Consulting
  • SEO Reseller

Contacts



8 800 2563 123

  emil@yoursite.com

 27 Division St, New York, NY 10002, United States