Apr 17, 2013ProgrammingComments (1)
Recently I was curious about the performance (in terms of access and assignment time) between class static attributes, object attributes, and array elements. Say if you're wanting to store some information that is accessed regularly, and want to know which method is the fastest.
Mar 4, 2013Programming
Logging PHP errors and warnings is important on both your production and development servers. Often times these messages go unnoticed, even if you have display_errors on.
To start logging errors, open up your php.ini file. Scroll down to or search for the line that has the error_log variable. It will probably look like one of these:
To start logging errors, open up your php.ini file. Scroll down to or search for the line that has the error_log variable. It will probably look like one of these:
Aug 2, 2012Programming
With Flash version 10, Adobe added the Vector class, which is similar to an Array but more strict. Each Vector can only contain data of the same type and its data type must be declared during instantiation. I'm not going to go over the syntax to use Vectors in this post, but they are very similar to Arrays and have a lot of the same methods and properties.
Jul 17, 2012Programming
If you're unfamiliar with object pooling, it is a way to speed up processing time by keeping objects in memory and reusing them, instead of always instantiating new ones and garbage collecting them.
This example uses package and custom class syntax. If you are unfamiliar with these, see my introduction to package and classes post.
This example uses package and custom class syntax. If you are unfamiliar with these, see my introduction to package and classes post.
May 20, 2012Programming
There are two common methods to determine if a property/attribute/variable of some object exists. Both use the property name as a string and neither rely on checking for an error report.
May 20, 2012ProgrammingComments (1)
This error is often caused by the accidental use of a colon (:) to terminate a statement instead of a semi-colon (;). The error report should give you the error location.
Apr 5, 2012Programming
Ternary is a short way to write if/else condition checks on a single line, and allows you to perform condition checks inline with variable assignments and more.
Apr 5, 2012Programming
The information in this post is outdated. Please use PDO with real (non-emulated) prepared statments to properly prevent MySQL injection.
Any data that comes from the client-side needs to be properly validated and escaped before using. This is extra important if you're using that data to form part of a database query. Always assume that your users will try to input incorrect information and special characters into fields, and do not rely on HTML or JavaScript to prevent this.
Any data that comes from the client-side needs to be properly validated and escaped before using. This is extra important if you're using that data to form part of a database query. Always assume that your users will try to input incorrect information and special characters into fields, and do not rely on HTML or JavaScript to prevent this.
Apr 5, 2012Programming
PHP is a fairly loose programming language, which causes many new developers (and experienced ones) to get lazy. If you suppress errors, you can get away with ridiculous things like using undefined variables, without anyone being the wiser. But just because you can get away with it, doesn't mean you should.
Apr 1, 2012Programming
When comparing two values against each other, it is common to use the "equals" operator (==), and this is fine as long as you have control over the values that are being compared. But what if you're comparing user input against a value, such as in a sign-in script or captcha? Using the equals operator can potentially leave you open for security issues, since PHP handles comparisons between different data types non-intuitively.
Mar 23, 2012Programming
Using PHP, you can change the whole site or redirect users to a different site when they browse from a mobile device, or just change the CSS.
Nov 20, 2011Programming
At some point when programming you probably realized that collision testing every object in your game is rather inefficient. A better way is to group objects based on their physical location in the game, and only collision test the bounds of the whole group. A quadtree does this, and can be used in 2D games to greatly speed up both collision detection and rendering.
Sep 26, 2011Programming
This guide is outdated now and only good for Apache 2.2 and PHP 5.2. To use newer versions, you may want to consider WAMP.
Here's a basic guide on setting up an Apache server with PHP and MySQL on your Windows computer to use as a developer environment.
Here's a basic guide on setting up an Apache server with PHP and MySQL on your Windows computer to use as a developer environment.
Sep 26, 2011ProgrammingComments (1)
If your site accepts user input, it's a good idea to understand the differences in newline characters between platforms and how to handle them (and it's just good to know in general). Say your site is running on a Unix host and receives comments or posts from Windows clients. Any HTML textarea form input sent from the Windows clients will contain newline characters that do not match those native to the Unix host. Likewise, if your site runs on a Windows host, the occasional Linux or Mac user will be sending non-native newline characters as well.