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...
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...
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...
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...
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.The first is using the hasOwnProperty method:
var myObject:Object = {name:'Jenkins'};
if(myObject.hasOwnProperty('name'))
{
// Do something
}
if(myObject.hasOwnProperty('name'))
{
// Do something
}
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...
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...
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...
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...
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...Page 1 of 4
