background preloader

PHP - Tutorials

Facebook Twitter

How to Create a PHP/MySQL Powered Forum from Scratch. In this tutorial, we're going to build a PHP/MySQL powered forum from scratch.

How to Create a PHP/MySQL Powered Forum from Scratch

This tutorial is perfect for getting used to basic PHP and database usage. Let's dive right in! It's always a good idea to start with creating a good data model when building an application. Let's describe our application in one sentence: We are going to make a forum which has users who create topics in various categories. Other users can post replies. CategoriesTopicsPosts These three objects are related to each other, so we'll process that in our table design.

Looks pretty neat, huh? I'll discuss each table by explaining the SQL, which I created using the scheme above. The CREATE TABLE statement is used to indicate we want to create a new table, of course. "A primary key is used to uniquely identify each row in a table. " The type of this field is INT, which means this field holds an integer. There is a user called John Doe. All the other tables have got primary keys too and they work the same way.

Simple PHP Class-Based Querying. Though it is usually advisable to use some sort of framework or CMS, sometimes a project is small enough such that those options would weigh down the development.

Simple PHP Class-Based Querying

However, even in smaller projects, separating presentational elements from backend querying should not be ignored. This tutorial will walk you through creating a basic class-based querying engine for PHP and MySQL. Step 1. Setup the Project The first thing we are going to want to do is make some specific files and directories. Make directories We'll need a new directory to hold everything. Add Files Then, inside /conf, we will make config.php.

DAL stands for "Data Access Layer" or "Data Access Link".In multi-tiered architecture, it is essentially used to translate database query results into objects and vice-versa. The Problem with PHP’s Prepared Statements. Understanding and Applying Polymorphism in PHP. In object oriented programming, polymorphism is a powerful and fundamental tool.

Understanding and Applying Polymorphism in PHP

It can be used to create a more organic flow in your application. This tutorial will describe the general concept of polymorphism, and how it can easily be deployed in PHP. 9 Useful PHP Functions and Features You Need to Know. Twice a month, we revisit some of our readers’ favorite posts from throughout the history of Nettuts+.

9 Useful PHP Functions and Features You Need to Know

Even after using PHP for years, we stumble upon functions and features that we did not know about. Some of these can be quite useful, yet underused. With that in mind, I've compiled a list of nine incredibly useful PHP functions and features that you should be familiar with. 1. Functions with Arbitrary Number of Arguments You may already know that PHP allows you to define functions with optional arguments. First, here is an example with just optional arguments: Now, let's see how we can build a function that accepts any number of arguments. 2. Many PHP functions have long and descriptive names. Think of it like a more capable version of the scandir() function. You can fetch multiple file types like this: Note that the files can actually be returned with a path, depending on your query: 3. By observing the memory usage of your scripts, you may be able optimize your code better.

Why You’re a Bad PHP Programmer. Create your First Tiny MVC Boilerplate with PHP. PHP with MySQL Essential Training. The Best Way to Learn PHP. Learning something from scratch is almost always an arduous affair -- you simply have no idea as to where to start, or not to start, to kick things off.

The Best Way to Learn PHP

I loathed learning about the idiosyncrasies of C++'s syntax when all I wanted to learn were some darn programming concepts. As I'm sure you can agree, this is a less than ideal situation. This is where the Nettuts+ "The Best Way to Learn" series comes into the picture. This series is intended to be your blueprint, your road map, your plan of action for learning your topic of choice! You don't have to worry about finding the best resources, sorting out the bad ones, and figuring out what to learn next. Today, we're going to figure out the best way to learn PHP. Assignment #1: Disregard the Naysayers If you're reading this, chances are that you've Googled a lot to decide which language to learn and how. Haters gonna hate! As the popular saying goes, haters gonna hate!

Assignment #2: Install PHP through [X]AMP Author: David Powers. A Better Login System. Net.tuts+ has published several great tutorials on user login systems.

A Better Login System

Most tutorials only deal with authenticating the user, which allows for two levels of security: logged in and not logged in. For many sites, a finer degree of control is needed to control where users can go and what they can do. Creating an access control list (ACL) system will give you the flexibility for granular permissions. Introduction Imagine you are running a great tutorial site that lets users learn about a wide variety of web development techniques. Your problem You want to restrict users' to only specific pages that their particular account allows access to. The solution Implementing an access control list will allow you a great deal of control over what users can and cannot access on your site. If you view the demo, available with the downloadable source code, you will be greeted with an index page that tests the ACL for each user.

Step 1: Create the Database Step 2: Database Include Step 3: Create the ACL Class. 20 Ways to Save Kittens and Learn PHP. 1a.

20 Ways to Save Kittens and Learn PHP

Read the Comments! It's easy to overlook the comments, but do yourself a favor and have a look through them. If you're getting an unexpected result from a function, chances are someone has spotted it and explained it in the comments. You can also pick up a plethora of great tips and ideas from the developer community by reading through comments. Object-Oriented PHP for Beginners.