Showing only posts with tag php

PHP Class vs Object vs Array Attribute Performance
PHPRecently 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...
Apr 17, 2013   Nick Vogt   Programming

How to Log PHP Errors/Warnings
PHPLogging 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...
Mar 4, 2013   Nick Vogt   Programming

PHP: Using Ternary Operator Condition Checks
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, 2012   Nick Vogt   Programming

PHP: Prevent MySQL Code Injection Exploits
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...
Apr 5, 2012   Nick Vogt   Programming

PHP: Avoid Using Undefined Variables and Indexes
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 5, 2012   Nick Vogt   Programming

PHP: Use Identical Operator When Comparing User Input (Equals vs Identical)
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...
Apr 1, 2012   Nick Vogt   Programming

PHP: Detect Mobile User Agent Using preg_match Regular Expression
Want a more reliable way to detect mobile visitors than the CSS media query? 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.

This method relies on the HTTP_USER_AGENT value in the $_SERVER super global. Since this value ultimately comes from the client's browser, it can be spoofed, though don't expect a large portion of visitors to know how. I wrote a post on how to spoof your user agent on Android for those curious...
Mar 23, 2012   Nick Vogt   Programming

Set up Apache, PHP, and MySQL on Windows
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. Sure, you could just download WAMP, but where's the fun in that?

If you currently have IIS setup with MySQL, you can leave MySQL installed. You will want to remove IIS prior to installing Apache though. It would require configuring beyond the scope of this guide to use both IIS & Apache concurrently. To remove IIS, you will want to choose the "Add/Remove Windows Components" or similar link on your respective version of Windows, which would be in the "Add/Remove Programs" or "Programs and Features" control panel...
Sep 26, 2011   Nick Vogt   Programming

Working with cross-platform newline characters & user form input
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...
Sep 26, 2011   Nick Vogt   Programming

Beginner JSON Guide/Tutorial (JavaScript, PHP, AJAX)
JSON stands for JavaScript Object Notation. It is a widely-used model for transferring variable data as text, and is often used in combination with AJAX to create the basis for highly-interactive, portable, and modular websites (Facebook, Twitter, etc).

If you are familiar with JavaScript objects, then you already know JSON! If you aren't, it is very easy to learn. A JavaScript object is just like an object in ActionScript 3 or an associative array in PHP, just with slightly different syntax...
May 17, 2011   Nick Vogt   Programming



Categories

All Posts
Computer Hardware
PC Gaming
Programming
Web and Internet
Miscellaneous

Tags

youtube
minecraft
skyrim
call of duty
crysis
facebook
actionscript
› php
javascript
tutorial

Series

ActionScript 3 Tutorials
PHP Tutorials
Game Reviews