PHP Tips & Tricks

Posted by videofun | 5:43 AM | 0 comments »

http://php.apachai.com PHP Tips & tricks

Here's what was popular in the PHP community one year ago today:

http://www.phpdeveloper.org/news/8820

Latest PHPClasses.org Releases:

* Id3v1
* Tag Cloud Generator
* impaginator
* Calcolo Codice Fiscale
* MdRGen
* Vote Image
* phpCode128
* Apriori
* Send Music to Last.fm
More: http://www.phpdeveloper.org/news/8814

PHP Password Security

Posted by videofun | 6:04 PM | , | 0 comments »

If you build websites that require users to register it’s your responsibility to keep their passwords safe. And if you’re storing the passwords in plain text then you’re not doing your job properly. It may be that, like Reddit, you think that storing passwords in plain text leads to a better user experience. I happen to agree with you. But then, like Reddit, what happens if your database is stolen? It’s not just your site that is compromised. Since most users use the same password on multiple sites, all those sites have also been compromised.

More: http://www.bigroom.co.uk/blog/php-password-security

Today's example was requested by a user called Devo. This example illustrates making an animated GIF image by creating the frames from scratch. It's been so long since I've really drawn anything so I decided to use text as the base for this animation.

You could of course use existing images to simulate motion or even strip frames from videos to create GIF animations. The example is pretty straightforward but please post any questions you might have.


More: http://valokuva.org/?p=46

Today I wanted to make a tag cloud, but all my searching proved fruitless - so I decided to stop being lazy and just work it out myself!

For my example, first you'll need a database that stores the keywords / search terms.

The way mine works is every time a search is run, I check to see if the term has been searched before. If it has, I update the counter field + 1. If the term has not been searched for before, I insert it with a counter of 1.

Alternatively you may store every search individually and use the GROUP BY clause to determine how many times the search has been run.

My query looks like this:


More: http://stevethomas.com.au/php/how-to-make-a-tag-cloud-in-php-mysql-and-css.html

This part 2 of 3 of my video series on creating custom functions in PHP. We continue from where I left off in part 1.


The Video: Custom PHP Functions - Part 2



More: http://www.killerphp.com/videos/13_functions_custom/functions-custom-part2.php

In real life I do not consider myself to be a tree-hugger, but as a developer: tree data structures and recursive technology totally get me going ;) Seriously though, they are very powerful ways to solve problems and often lead to elegant & reusable solutions.

More: http://kevin.vanzonneveld.net/techblog/article/convert_anything_to_tree_structures_in_php/

PHP has a built-in command called __HALT_COMPILER__. This command Halts the execution of the compiler. This can be useful to embed data in PHP scripts. Below is an example of a self-extracting php script. When executed, a second php file will be extracted in the same directory called testscript1.php.

More: http://www.whenpenguinsattack.com/2007/10/09/how-to-create-a-self-extracting-php-script/

Official
Current version: 1.0.2.
Web site
Manual
Mailing List

Tutorials
BostonPHP Framework Presentations by Matthew Weier O'Phinney
Getting started with the Zend Framework by Rob Allen

Forums
zfforums.com

ZF activists: blogs, personal pages
Matthew Weier O'Phinney
Pádraic Brady
Rob Allen

Other
Unofficial PDF version of manual
zftutorials.com - link repository.
zflinks.com - link repository.
zftalk.com - unofficial IRC channel.

More: http://www.alexatnet.com/node/45

Create Ajax Login page

Posted by videofun | 6:51 PM | , | 0 comments »

Article shows how to create Ajax forms with server-side actions using the Dojo toolkit and Zend Framework. It guides you through creation of a sample user login form that uses dojo.io client-side packages and Zend_Controller and Zend_Filter_Input server-side packages.

A few days ago I understood the right usage of the framework. Frankly speaking, it does not help with creating Web forms—it has no high-level complex components like TDataGrid in PRADO or even Repeater in ASP.NET. And what I understood is that it is not Zend Framework’s business how developers are creating their forms and here is a reason for this: modern pages are created with a lot of JavaScript and, I believe, are created with client-side components, not server-side. For example, Dojo toolkit or Backbase framework has a lot of JavaScript components for creating powerful pages. Basic form controls, complex components like DataGrid are ready to use and Zend Framework only should help with providing them with data and performing various operations with a controller. And now it has enough to serve “rich clients” requests.

More: http://www.alexatnet.com/node/13

This article contains information on how to improve your application stability by controlling how the changes affect the Model-View-Controller Zend Framework application. As a result, you will be able to deliver better software to your customers and reduce the time needed for testing of the software.
Testing should be automatic

The problem of all changes in a software application is that they can damage it. The effect can be various, from hardly-detected change in complex calculation to just a "big crash" when user just runs it or, in case of the Web application, types site URL in browser. There is no exception to this rule and disregarding application size it should be checked after any change. It is possible for small applications to just manually repeat some use cases and test that everything works as expected. But if application testing requires more than a few minutes then only few of us have enough obstinacy to repeat this boring and monotonous work after each change. The idea of automatizing the process comes into mind just after second such check and, hopefully, there are enough robust and powerful automatic testing solutions, also known as unit testing frameworks. They provide developers with tools and guidelines on how to test software automatically.

More: http://www.alexatnet.com/node/12

This coding tip demonstrates how to deal with PHP core notices and warning (aka recoverable errors) in the exception way, using try/catch statement.

The way on how PHP informs you about the errors, warnings, and notices in the script is one of the PHP messy areas. The half-way OOP changes, made in PHP 5, did not change the way on how PHP handle some runtime issues, like accessing an undefined variable or writing into read-only files. In the same time, new Exception-based error handling, which was added into the engine, provides the developers with the standard and time-proven way of dealing with exceptions in the code.

more: http://www.alexatnet.com/node/23

Looking over the PHP5.2 changelog I noticed that somewhere along the way PHP5 seems to have picked up a provocatively named pair of classes, DateTime and DateTimeZone.

There is something fundamentally brash, brazen even, to releasing a class named DateTime. As a calendar geek I imagine upon seeing “new DateTime()” I feel something akin to what an old thespian feels when they see a company putting on a production of the Scottish play — it’s a decidedly mixed emotion. But I’m going to bump my way through learning how to use this new DateTime lib, bringing all my preconceptions about how it should work. The odds of this being interesting to you is probably nil unless you’re in one or two very small cliques, feel free to read on, or browse away.


More: http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/

Pretty thumbnails

Posted by videofun | 6:27 PM | , | 0 comments »

Today's example is about making pretty thumbnails by combining a drop-in shadow with round corners.

The image is first scaled down to create a thumbnail. Imagick::thumbnailImage also strips all the associated profiles to make the image optimal to use in web applications.

The next step is to round the corners of the image. This is pretty trivial task but you should keep in mind that usually larger x and y rounding values give the optimal results when rounding the corners of a larger image. Generally it is pretty easy to find the suitable values by poking around with the parameters and making a formula out of it.

More: http://valokuva.org/?p=45