New Website

I've made a new website, as lynx.io is dead. You can find it here: http://macr.ae/—it's similar in format to lynx.io, but has better articles, and they're all written by me.

Loading

lynx.io is loading, it shouldn't take long. If JavaScript is disabled, please enable it - the site will work better with it enabled.

 

No articles

:-(

PHP AJAX Best Practices

As the use of AJAX becomes more and more popular, it becomes increasingly important that when responding to AJAX requests in PHP, there are some best practices that you should stick to in order to make dealing with the response at the other end a lot easier. In this article, I will cover the more important best practices, and explain how they are relevant and how you can do them. Read more

Rumour Debunked: Single quotes vs double quotes in PHP

There is a popular rumour that while writing PHP, you should use double quotes wherever possible. This used to be true - before PHP 5.1 was released, there was a significant difference in speed between double and single quotes, and it was definitely a good idea to use single quotes wherever possible. PHP 5.1 included some optimisations to the opcode parser which improved the double quotes parsing time, and since then, using double quotes hasn't been an issue. Read more

IO: Accepting command line input in PHP

While writing an application, you may sometimes feel the need to create a script that can communicate with the user through the command line – perhaps you don't feel the need to write an entire web GUI for your install script, or you just want to experiment. Read more

Utilising the MVC architecture

The Model-View-Controller (MVC) architecture is an architecture most commonly used to separate what is known as "domain logic" - the code that powers the backend - from the user interface - what the user sees. This makes your code clearer, easier to work with, and has the advantage that you can very easily had multiple people working on the same project without conflicts, and without the need for a version control software such as Git or SVN. Read more

Optimising your website for mobile devices

Mobile phones are being used to access the Internet with increasing frequency, and as more people buy better phones and mobile Internet gets cheaper, we will find our websites being hit by a greater number of mobile devices. Only one problem: your huge, image heavy design on your forums or blog takes several minutes to load due to slow network speeds, and even then, it uses more resources than the phone has and goes off the screen. Solution? Get a mobile website. Read more

Using mod_rewrite to create friendlier URLs

mod_rewrite is an Apache module used for rewriting a URL at the server level, making the URL a lot friendlier. For example, if a user goes to example.com/article/421 they will in fact be shown example.com/article.php?id=421, but they still think they're accessing /article/421. This is a different to redirect, as a redirect completely changes the page the user is on, telling them that they're on article.php, but mod_rewrite does not - this makes the URL look a lot friendlier, while not requiring millions of pages. Read more

Running PHP applications from the command line

I've always found it useful to be able to run PHP applications from the command line: not only does it allow me to quickly view the output of my code from the command line - where I do the majority of my developing - but it also allows me to make proper command line applications from within PHP. Okay, quite a lot of stuff is not possible, but it's still fun. This applies to Unix only, I believe. Read more

PHP array functions

There are a huge amount of functions to deal with arrays in PHP, but I will be going through just a few of the most useful or interesting ones. If you would like me to add a function or two to this list, just tell me and I'll do my best. Read more

The If Shortcut: The Ternary Operator

The ternary operator is a shortcut comparison operator that replaces an if-else statement in a PHP script. If you use a lot of if-else statements in your scripts, using the ternary operator can shorten your code hugely. The ternary operator is very simple to use, but it does tend to confuse new PHP programmers. Read more

What are regular expressions?

Regular expressions are a way for programs to search for a particular pattern in a string. For example, they can be used to find strings starting with "www.", or to see if some user input is a valid email. Regular expressions are incredibly useful for validating user input and also for the mod_rewrite function of the Apache server. Read more

Sleeping in PHP

I've seen a few people asking how they can sleep or pause their PHP script, so in this article I am going to do two things - I am going to explain how you can sleep your script in PHP, and I am also going to ask this question: Why would you want to? Read more

PHP Data Objects (PDO) - The Basics

PHP Data Objects (PDO) is an extension for PHP that provides the developer with yet another way to access databases using SQL in PHP. This is the first half of a two-part tutorial. In this part, I will explain how to connect to, select rows from, and insert data into a database; in the next part, I will cover some more advanced stuff. Read more

Markdown Cheat Sheet

# This is an <h1> tag
## This an <h2> tag
###### This is an <h6> tag

Inline markup: _this text is italic_, **this is bold**, and `code()`.

[Link text](link URL "Optional title")
[Google](http://google.com/ "Google!")

![Alt text](image URL)

![This is a fish](images/fish.jpg)

1. Ordered list item 1
2. Ordered list item 2

* Unordered list item 1
* Unordered list item 2
* Item 2a
* Item 2b

And some code:

// Code is indented by one tab
echo 'Hello world!';

Horizontal rules are done using four or more hyphens:

----

> This is a blockquote

This is an <h1> tag

This an <h2> tag

This is an <h6> tag

Inline markup: this text is italic, this is bold, and code().

Link text Google

This is a fish

  1. Ordered list item 1
  2. Ordered list item 2
  • Unordered list item 1
  • Unordered list item 2
    • Item 2a
    • Item 2b

And some code:

// Code is indented by one tab
echo 'Hello world!';

Horizontal rules are done using four or more hyphens:


This is a blockquote

Toggle MarkDown / HTML (t), full reference or close this