I've just released my PHP Infusion Extension to enhance the functionality and the usability of the PHP scripting language. I'll offer you a few of my toys I've developed somewhen under the use of PHP Infusion to show you how you can simplify your code with a few new functions. I want to share 3 calculation classes at this time - take it as a afterwards christmas present ;)xColor - a color calculation classI needed a bunch of functions to perform calculations on color values.... Read More »
While there are a lot of methods for you to resize images with php, we will be using extension gd this time. Make sure you or your hosting company has installed it in the php distribution by running[code]<?phpif (extension_loaded('gd')) { // return true if the extension’s loaded. echo 'Installed.';} else { if (dl('gd.so')) { // dl() loads php extensions on the fly. echo ... Read More »
It’s sometimes cumbersome to handle uploaded files – checking if it is really uploaded, moving and renaming. Why not writing all these chores into a class and make our own file upload script?First we are going to create a simple class to handle uploaded files and move them to some place we designate for convenient access.The PHP Class (PHP5, Uploaded.class.php)[code]<?phpclass Uploaded { private $field_name = '';... Read More »
You can send emails very easily with PHP by the help of mail() function, but how does one send attachment attached to that email?You’ll still use mail() function, but with a little more twists in the header argument – yes, the content of the attached file is actually encoded into the header of the email, can you believe that. Big head.Unfortunately, it’s a pain in the ass every time you have to get through all the chores needed to attach and encode th... Read More »
It’s also a free one and a rather easy one too. You should be able to do it yourself. To create a working contact form, you need the front end and the back end. The front end presents the form to the website user and the back end accepts the data sent from the form by the user and take any necessary actions such as relaying the message to your email.Front end (HTML)Simply copy this HTML form and paste it into your web pages where you want it to be, such as on the sideb... Read More »
Eric has create an article to help our readers learn how to correctly use object orientativity in PHP by the use of PHP classes.
When you start working with PHP, you'll find that there's many common tasks that you constantly have to type the same code for. Some of you may have figured out by now that making those tasks into a function will save you a little bit of time when you want to reuse that code. Y... Read More »
The hardest concept I've tried to understand since beginning to use PHP was that of classes. I'd never used a database engine but learning to use MySQL, at least for the more basic functions, was a breeze. Having never used OOP before, classes were novel as well, but understanding the theory and why it was useful escaped me. I knew they must be powerful as "everything" is programmed using OOP, but for the life of me, although I thought I understood the mechanics, I couldn't see the usefulness... Read More »
Right lets get straight to it as this is only a quick tip, do note though that we’re only scratching the very surface of PHP classes.
We’ll be creating two files, our main page index.php and our class file class.helloworld.php. The only thing we’ll need on our index.php is the code below and the calling of the class which we&... Read More »
What are classes, you ask? Classes are object-oriented programming for PHP. What is object-oriented programming? Object-oriented programming consists of three main vocabulary words: classes, methods, and objects. An object is basically a data structure (also known as an abstract data type), which are encapsulated in a set of routines known as methods. A class is a collection of methods and objects. What's the purpose of classes in PHP? It's the same reason as any other programming ... Read More »
For lack of a better example right now, i'm going to show you how to create a simple page object. The page object encompasses a few of the basic page necessities in building an HTML page. Now, there is a lot more you could do with this class, but i'm going to keep it simple for the time being. You guys can expand on it if want later. Okay, lets start by looking at what the basic elements of an HTML page are. First, you have the open and closing... Read More »