PHP OO tutorials

Best way to learn scripting / program is easy. Just write the code and see the result.

With the progress of OOP approach in field recently for our team make its ‘hard’ to adapt such change in mindset :

Procedural vs Object Oriented Programming

With case codeiginter,  we must learn the basic of OOP in PHP. Starting by dumping php4 and use php5 for production release.

Thanks to a lot of tutorial about OO in internet world, some of them are :

  1. Tutorialized
  2. Codewalkers
  3. Massassi
  4. KillerPHP, very good. With video too.

I myself more familiar with book, as I can carry it whenever I want and read it in my bed. When I feel I like to practice I’ll dive to my laptop and try to code.

Some books ( I ordered some in Amazon ) are :

  1. PHP 5 Objects, Patterns, and Practice
  2. CodeIgniter for Rapid PHP Application Development

From amazon description :

CodeIgniter (CI) is a powerful open-source PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter is an MVC framework, similar in some ways to the Rails framework for Ruby, and is designed to enable, not overwhelm.

read more »

nl2br, new line to br

I just forget this function when my friend ask me about strangeness in his data he store in mysql.

He has address data in <textarea></textarea>, new line not converted to br as he thing. He just see all the input just store in single line.

After search for a while I remember this gold function :

nl2br () , new line to br

just make temporary variable before as :


now $address will contain <br> tag in mysql database.

This post for remind me in future 😉


php explode() and wordwrap()

Whats the different of explode() and wordwrap() ?

Answer :

just see this example for explode()



//we need to split the component to date, month and year


// we use – as tool to separate, now print





Wordwrap will ‘wrapping’ user input, like formatting crazy user who type ‘aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa’ till he satisfied and brake our guestbook table.

Just make sure to add number bigger than 0 to enable wordwrap.

101 CodeIgniter Resources

CodeIgniter already attract my attention since version 1.5, we even try to build application based on it.

Beside its clear documentation, their user support awesome too.

I’ll try to collect every resource that might useful to share with others who want to learn codeigniter.

This post will be update regularly as soon as I get another resource 🙂

CodeIgniter Main Page

1. Download site

2. User Guide

3. Wiki

4. Forum

CodeIgniter Video Tutorials

1. Hello world, introduction to CodeIgniter

2. Create a blog in 20 minutes

3. Derek Allard Video

CodeIgniter Books

1. CodeIgniter for Rapid PHP Application Development

CodeIgniter Tutorials

1. Introduction to Code Igniter: Part 1 by Godbit, learn about CI structure. starting the case of making form.

2. Introduction to Code Igniter: Part 2 by Godbit, form continued.

3. Introduction to Code Igniter: Part 3 by Godbit, CI interact with database.

4. Pagination with Code Igniter by Godbit, make navigation easy with paging in CI.

5. Code Igniter Template Tutorial by Eric Barnes, separate logic with presentation.

6. Templating with CodeIgniter, templating study case.

7. Using Zend Framework components in Code Igniter, integration zend framework into CI.

8. Building an RSS Feed in Code Igniter, Derek Allard show howto build RSS with CI.

9. Using Oracle with PHP and CodeIgniter, Oracle and CI teamed together. I use oracle xe instead.

10. Forms in CodeIgniter Views, use don’t repeat yourself concept 🙂

11. Checking CodeIgniter out of the Subversion Repository, Derek show how to use subversion of CI.

12. SimplePie RSS class and CodeIgniter, simplepie and CI work together.

13. Building a Complete CodeIgniter Application: Part 1, by Jim O’Halloran. Build feedignitation from scratch.

14. Building a Complete CodeIgniter Application: Part 2, by Jim O’Halloran.

15. Building a Complete CodeIgniter Application: Part 3, by Jim O’Halloran. Eliminate security problems.

Last Update : January 09 2008

Latest news : Code Igniter 1.6 released!, read more from DerekAllard blog.

Make lowercase followed by uppercase data

Question :

I have table A with field id, name and address. The data in name field seem not consistent, big letter name sometime found in record. How to update that field with uppercase in name field. For example :

                 id              name                                       address

                 1               FreAKHolicz  wORker            the moon

                 2              tHE atMOSFER bluEZ            nowhere

FreAKHolicz  wORker must change to Freakholicz Worker

Answers :

1. Looping

2. Use strtolower() function followed by ucwords() function.

example code :


$query=mysql_query("select id,name from table A");



//change to lower case

$name1=strtolower($name); // will make FreAKHolicz  wORker  into freakholicz worker

//change to uppercase

$name2=ucwords($name1); // will make freakholicz worker into Freakholicz  Worker

//now using $name2 as variable to update name field

$update=mysql_query("update A set name=’$name2′ where id=’$id’");



since it’s looping, all good record also examined by scripts until no record left, using another conditional condition would bring another result.

P.S :

  • Use ucfirst() to change only first alfabet
  • Its possible using many function in one operation such as :  $name2=ucwords(strtolower($name));