2011年11月2日星期三
2011年11月1日星期二
Developer Drive: Create Your Own CRUD App with MySQL and PHP
On the Developer Drive blog today there's a new tutorial helping you build out a simple CRUD (create, read, update and delete) system using a MySQL backend. This is just the first part of the series, introducing you to some concepts and getting the ball rolling connecting PHP and the database.
You're may be wondering what exactly CRUD is. CRUD simply stands for Create, Read, Update and Delete and it is the one of the fundamental principles of programming logic that can be expanded and applied to larger projects. For example, let's imagine we're creating a social network and we like to have the ability for users to create accounts, edit and update information for those accounts and also delete said accounts; that is CRUD at work.
This first part covers the structure of the database that'll make up the storage and includes a brief snippet of code to connect your PHP to the database (using PDO).
PHPMaster.com: Using the Ternary Operator
On PHPMaster.com today there's a new tutorial showing the use of a sometimes overlooked (but very handy) alternate syntax that PHP includes - the ternary operator, a short-hand if/else.
You're probably already familiar with PHP's if statement. It's very similar to its counterparts in many other programming languages and represents one of the most fundamental concepts in programming. [...] But there's a way to build on this concept and increase your $coolFactor a bit in the process. Allow me to introduce you to the ternary operator, which serves as a shorthand notation for if statements.
They introduce the ternary operator's syntax, the ":" and "?" operators and includes a few pieces of code showing its use. Thankfully they also include a warning - don't overuse or abuse it...and especially don't nest them - that just leads to headaches.
ArsMagnaTutorials: FuelPHP Tutorial Videos
On the ArsMagnaTutorials YouTube channel has posted three video tutorials (so far) covering the Fuel PHP framework, introducing you to some of the core concepts behind using this powerful framework.
The three videos in the series give an overview of:
- Installation and configuration
- Folders and structure the framework provides
- Controllers, view and using the HTML5 boilerplate.
You can find out more about Fuel on its website and more about the HTML5 Boilerplate here.
2011年10月31日星期一
PHPMaster.com: Localizing PHP Applications "The Right Way", Part 1
PHPMaster.com has a new tutorial sharing what they call the right way for localizing PHP applications with the help of PHP's gettext functionality.
Localizing software applications in general used to be a cumbersome and error-prone task resulting in a lot of messy code. Some developers even use different versions of code for the same application but for different locales, which makes managing the codebase practically impossible. Enter gettext, the wonderful open-source tool that will make your life easier by allowing you to concentrate on your code. Localization becomes a matter of writing separate translation files for the target language, which can easily be done by a translator using Poedit.
They help you get your environment set up - PHP and a href="http://poedit.net/">Poedit, a gettext catalog editor - for both linux- and Windows-based OSes. They walk you through the creation of a simple project and a few basic "hello world" tokens. Using the files is as easy as setting the correct locale and default domain for your application. Then output is just a basic echo away.