PHP Tutorials

  • By
    Checking For Leap Year Using PHP

    One part of programming that seems pretty static is dealing with dates. The calendar is a set system of rules that doesn't look to change. The only part of the calendar that can be variable is a leap year, which changes every four years...

  • By
    PHP Function – Calculating Days In A Month

    All developers keep a tool box of useful functions and classes that they pick up or write along the way and this PHP came to me while I was writing an event calendar page for a customer.I should mention that PHP does offer a

  • By
    PHP Optimization – Using A Timer To Benchmark Code And Increase Speed

    One of the best parts about being a programmer is that there's seemingly always a better way to do things. A simple code tweak can drastically improve the execution time of your web application. The faster your application executes the quicker you release precious server resources.The...

  • By
    Adios Means Goodbye – Browser 301 Redirects In All Languages

    Browser redirects, especially 301 "permanent" redirects, are essential to all good web applications. Regardless of language, browser redirects can: provide safe URL forwarding to gather GET and POST variables and process them without risking data and processing integrity by a browser refresh send users and search engine...

  • By
    Fixing IIS & PHP Variables – Set $_SERVER[‘REQUEST_URI’] Yourself

    About 8 months into my programming career I needed to code a content management system (CMS). This was quite a challenge so early into my professional journey but I was up to it. The front-end was the easiest part of the project -- a...

  • By
    PHP Shorthand If/Else Using Ternary Operators (?:)

    An essential part of programming is evaluating conditions using if/else and switch/case statements. If / Else statements are easy to code and global to all languages. If / Else statements are great but they can be too long.I preach a lot about using shorthand...

  • By
    PHP Email Validator – Email MX DNS Record Check

    Validating an email address is one of the hardest feats on the web. A valid email can be marketing gold, but an invalid email address is dead weight. Not only does it require a CPU-taxing PHP regular expression ("/^[A-z0-9\._-]+"."@" . "[A-z0-9][A-z0-9-]*".

  • By
    PHP Force Download – Keep Track of What’s Going Down

    A force-download script can give you more control over a file download than you would have providing a direct link. Using a force-download script, you can:Validate that a person is logged inIncrement a counter in a text fileConnect to your database and log IP information...

  • By
    PHP Email Encoder – Prevent Spam Bots From Collecting Email Addresses

    Police have criminals. PETA has Michael Vick. Bud Selig has Barry Bonds. Programmers have spammers. Email spam is probably the most annoying part of my job. Whenever I'm placing email addresses on a page or coding another web form, I have to expend...

  • By
    Facebook PHP Code Leak Analysis

    It came to my attention over the weekend the PHP code to the Facebook homepage has been posted online. To avoid legal difficulties, I will not post the code on this website but you may find the code here. As a PHP programmer, I...