Archive for the ‘php’ category

Has PHP Killed JSP?

March 7th, 2013 Leave a comment
Has PHP Killed JSP?

Having recently written an article on Apache vs Tomcat, someone commented to me that they had never had occasion to use Tomcat: since they had started web developing, PHP had been the dominant language on the web landscape, and they saw no reason to learn JSP. In fact, they asserted that JSP is a dying language- one that PHP has effectively superseded. Were they right? According to a W3Techs.com study, as of February 2012 PHP held a commanding lead in web presence: of the dynamic sites evaluated, 75% used PHP. JSP’s share was a stark contrast, trailing at 10%. It would… View full post »

PHP Templating: Pros and Cons

February 3rd, 2013 Leave a comment
PHP Templating: Pros and Cons

Quite a few people now have started using and enjoying templating systems in PHP to more cleanly separate design and development. For those unfamiliar with the term, PHP templating is a system (like “Smarty”, one of the most popular for PHP) that allows programmers to divide application logic from content presentation. It uses tag-based mechanics to allow “tags” defined in HTML files to be replaced by data that is generated by PHP code behind the scenes. It makes for very nice and usable templating, as opposed to the sometimes-messy approach of blocking off sections of <?php tags and having dozens… View full post »

5 More Useful PHP Snippets

December 14th, 2012 Leave a comment 1 comment
5 More Useful PHP Snippets

Given the success of our last PHP Snippets article, we’ve decided to go ahead and find a few more useful PHP snippets. Without further ado, here are some more useful (and a bit more complex) PHP snippets for use! 1. Generating CSV Many people have come up with their own functions for generating CSVs, but the problem is that many of them fail to take into account wayward quotation marks or apostrophes that will bring down their CSV and make it harder to parse later. A much better idea is to take those into account, like so: function make_csv(array $to_csv, $file = false)… View full post »

Is PHP Truly A Bad Language To Write In?

November 9th, 2012 Leave a comment 3 comments
Is PHP Truly A Bad Language To Write In?

Despite it being 2012 and the PHP wars having been waged for years now, many people still continue to rail against PHP as a programming language. The complaints about it are numerous, and many of them are warranted to some extent: non-standard function names, exceptions to operator usage, and non-standard inheritance of ideas from other languages are just a few of the legitimate complaints that come out of the anti-PHP camp. Many of them, however, curiously seem to center around one core complaint: that it leads programmers to write “bad code”, either because of the reasons listed above or because… View full post »

Sending Text Messages with PHP

September 21st, 2012 Leave a comment 1 comment
Sending Text Messages with PHP

These days text messaging is everywhere and not just for personal conversations. Companies are using text messages to send you coupons, let you know when you bills and statements are ready or that your dry cleaning can be picked up. Text messaging seems more convenient than making phone calls and creating your own PHP script to send these messages is a very easy thing to set up. Get on board with these other companies that have found how convenient text messages are for their customer and start integrating text messaging into your PHP applications. In this… View full post »

The $_SERVER PHP Variable In-Depth

September 18th, 2012 Leave a comment 1 comment
The $_SERVER PHP Variable In-Depth

Whether you are new to PHP or have been working with it for a while, you have probably heard of the $_SERVER variable. PHP automatically stores some important information in the $_SERVER super global array that can be used in your scripts or to help you troubleshoot problems with your requests. If you are used to previous versions of PHP, the $_SERVER has taken the place of the $HTTP_SERVER_VARS array. In this article I will show you some of the useful attributes of the $_SERVER array so you can begin using them in your scripts. This useful tool… View full post »

Tutorial: Uploading Files in PHP

August 15th, 2012 Leave a comment
Tutorial: Uploading Files in PHP

Once you have learned the basics of using forms in PHP, the next step is to begin working with and manipulating files. With PHP, you can allow users to upload files to the server and then use or store them. In this tutorial we will use a basic HTML form with a PHP script to upload files to your server. To begin, we will create an HTML form in our upload.htm file. <html> <head> <title>PHP File Upload Example</title> </head> … View full post »

10 Useful PHP Code Snippets

June 14th, 2012 Leave a comment
10 Useful PHP Code Snippets

Whether you are just learning how to write PHP or you are a veteran developer, you soon learn that there are things you do or situations that you encounter often. These 10 snippets provide a broad range of useful elements that you will often need to use as you write PHP applications. I hope you will find them useful and, if kept as a cheat-sheet, you can refer back to it at any time without having to do a lot of internet searching for the answer. 1. Getting a Remote IP Address A quick and easy way to get the… View full post »

Tutorial: PHP Form Handling

June 8th, 2012 Leave a comment
Tutorial: PHP Form Handling

One of the key things to learn if you are just starting to learn PHP is how to handle forms. This process seems to stump new developers to PHP but this shouldn’t be a big obstacle. PHP has many features that allow for simple data gathering and easy form processing. In this tutorial, I will discuss how to use the action method of the form and show you how to create a simple form that you can use on your site that will allow your visitors to contact you via email. This will require the… View full post »

Generating PDF files with PHP

May 2nd, 2012 Leave a comment 1 comment
Generating PDF files with PHP

If you are looking for a way to convert HTML to PDF, check out this post. This article continues the PDF series but addresses a slightly different task. In PHP, generating files is easy, but sometimes you need to have complete control over the content generation such as how documents are generated for printing. This is when using PDF files is handy because they give you a greater amount of control than HTML or other document types. Here, I will walk you through how to create PDF files dynamically using PHP a free tool called Free PDF library (FPDF)… View full post »

Facebook Just-in-time Compiler for PHP

March 30th, 2012 Leave a comment 1 comment
Facebook Just-in-time Compiler for PHP

Now that Facebook is up to 800 million users they are working hard to find new ways to serve all of their users in a way that keeps their quality of service at a high level. To do this, Facebook has created a Just-in-time or JIT, compiler for PHP to help handle its PHP-based web pages called HipHop Virtual Machine (HHVM). For those of you unfamiliar with the idea of Just-in-time compilation, here is a little primer: JIT compilation is a method of compilation that allows for the improvement of runtime performance because the code is not compiled until it… View full post »

Generating Better Random Numbers With PHP

March 23rd, 2012 Leave a comment
Generating Better Random Numbers With PHP

For most developers, when we talk about “random” numbers we are talking about two ideas: Predictability and Bias. Both are closely related but have some fundamental differences. In this article I will discuss these two ideas as well as evaluate how random numbers are achieved using PHP so you can have a better understanding of them the next time you need random numbers in your program. To begin to understand how to generate better random numbers, you must first understand how random numbers work. As stated before, random numbers must have two characteristics: predictability and bias. Predictability… View full post »

PHP: Insert Text Into File at Position

March 7th, 2012 Leave a comment
PHP: Insert Text Into File at Position

This is a small PHP tip I used to insert arbitrary text into a file at a specific position. There are times when you need to insert (or rather, append at a given position) an arbitrary text into a file from within your PHP application. It only takes a few lines of code, but I didn’t find an exact solution to this on Google, so I decided to share my own solution with you. The link below is as close as I got to what I needed: http://www.neoseeker.com/forums/45/t1544597-php-append-text-to-file-at-specific-position/, but the code from there was overwriting the contents of the file… View full post »

PHP Training: Online vs. Classroom

January 29th, 2012 Leave a comment
PHP Training: Online vs. Classroom

If you are looking to learn how to write Web applications in PHP, you may be considering online or traditional teacher-lead classrooms to help you. There can be many factors in the decision to learn PHP online or to take a class in-person, and for some, this can be a difficult decision to make. This article discusses the pros and cons of each method of PHP training to help you find the learning method that is going to suit your needs best. PHP isn’t a new programming language, and there is a wealth of information on it on… View full post »

htaccess for PHP Error Logging – An In-depth How-to

January 11th, 2012 Leave a comment 1 comment
htaccess for PHP Error Logging - An In-depth How-to

For PHP users running Apache, we often want to be able to suppress our PHP errors from visitors so we can protect and handle those errors. We also want to log those errors since error tracking is an excellent way to troubleshoot potential problems. Catching these errors and monitoring them is a better solution than trying to catch and handle them during the user’s session. This tutorial will show you how to enable PHP error logging and error handling via .htaccess. For Developers New to htaccess If you are a developer that has never used the .htaccess file, here… View full post »