PHP new syntax reference

PHP introduces new language features with every release. As such, it can be difficult keeping track of them all and remembering which features can be used in which version. So below we list the major syntax changes in each version along with a short example.

PHP 7.4

Typed properties

Type declarations on class variables.

class Foo
    public int $bar;
    private string $qux;

Arrow functions

Shorthand syntax for anonymous functions; includes automatic variable binding (no need for ‘use’).

$foo = 3;
$multiplyFoo = fn($n) => $n * $foo;
Continue reading PHP new syntax reference

How Internet Explorer conditional comments work

Conditional comments are a special feature of the Internet Explorer browser that controls the display of any HTML content based on whether the visitor is using IE or another browser, and which version of IE they are using. They are supported by Internet Explorer versions 5 to 9 inclusive; from version 10, IE no longer supports conditional comments.

I’ve seen a lot of comments on websites and forums that misunderstand how condition comments actually work, so this post is an attempt to remedy that.

Continue reading How Internet Explorer conditional comments work

Alternate voting buttons for Question2Answer

Here is an alternate style of voting buttons for popular open source Q&A platform Question2Answer. The default setup is fine – besides the bad image quality – but this setup gives the voting a little more focus.

Q2A voting styles Default Q2A style on left; my arrangement on right.

Because the buttons are split up, implementing this requires some changes to an advanced theme.

Continue reading Alternate voting buttons for Question2Answer

Better icons for Question2Answer

Question2Answer is a popular open source platform for building Q&A sites. It’s a great piece of software but the default theme leaves something to be desired. In particular, the icons used in various places around the site aren’t the best, so I made some changes to the voting arrows and best answer stars. Problems with the default setup:

  • The voting buttons are poor quality: they have fixed transparency due to the GIF format and look “scratchy” around the edges.
  • The images are spread across 3 files – vote-buttons.gifselect-star.png and selected-star.png – which means multiple HTTP requests.
  • The best answer stars have solid colour backgrounds, not transparent – if you don’t have a white background in your theme or blue background for the best answer then a square shows through.
  • Two of the stars are almost identical so no need for separate images.

Continue reading Better icons for Question2Answer

Markdown editor plugin for Question2Answer

Question2Answer is a popular open source platform for building Q&A sites. Version 1.3, released last November, introduced a plugin feature to allow for further extending Question2Answer without editing core functionality. Since then I have – very slowly – been working on a Markdown editor plugin for better formatting of posts. Q2A actually comes with a WYSIWYG editor, however Markdown has several advantages:

  • It’s a simple markup format that is readable as plain text.
  • It uses a standard textarea and is therefore compatible with more browsers, including mobile devices and browsers without Javascript support.
  • It defines a neat set of allowable elements, including code, block quotes, lists, links and images.
  • Markdown intrinsically creates much better HTML code. If you have ever seen the HTML output of CKeditor or TinyMCE, you’ll know how plain terrible they are with even simple formatting.

Continue reading Markdown editor plugin for Question2Answer

Building Joomla components, the easy way

Joomla is our Content Management System (CMS) of choice at Infused Design. It’s simple to set up and customise, and is easy for our clients to get a handle on updating their own content. There is also a large array of add-ons, known as extensions, which enhance the core functionality and provide additional features such as contact forms, galleries and even full online shops.

Behind the scenes of Joomla 1.5 is a huge framework that covers all the aspects of displaying content, including component, module, plugin and database handlers. This can be a bit daunting at first, but fortunately there are some shortcuts. This article looks at creating custom Joomla components quickly and easily by bypassing most of the official framework.

Continue reading Building Joomla components, the easy way

Deprecated HTML 4 elements

There are several HTML elements and attributes that have now been declared deprecated by the World Wide Web Consortium (the organization that sets HTML standards). ‘Deprecated’ means that the elements no longer serve a purpose and have been replaced by other methods, mostly involving cascading stylesheets (CSS).

Although it is recommended that web browsers continue to support them, eventually they will become obsolete. This page lists all the deprecated elements and attributes of HTML 4, and specifies the recommended replacements for them. You will need a basic understanding of CSS to implement most of these.

Continue reading Deprecated HTML 4 elements