andPHP.com

Web Development Tips, Tricks & Much More

I’m going to show you how to automatically update the copyright year of your website without the use of PHP. I have been seeing a lot of posts about, how to update the copyright notice of your website using PHP’s date() function. What about those people whose websites are not PHP Diven?

Well, you can do something very similar using JavaScript. All you need is access to your HTML files.

Writing the Display Copyright Function

We are going to write a Javascript function that will output Copyright © [current year]. Where [current year] is … you guessed it, the current year.

<script type="text/javascript">
//<![CDATA[
/**
 * Function looks for element whose id is copyright and
 * inserts a dynamic copyright notice with the current year
 */
	function DisplayCopyright(){
		var d = new Date();
		var e = document.getElementById("copyright");
		e.innerHTML = ("Copyright © " + d.getFullYear());
}
 //]]>
</script>

Read the rest of this entry »

Help Saving MySQL

Last year Sun bought MySQL. Now, Oracle is trying to buy Sun. If that happens Oracle will own MySQL. This is not a big problem in my mind, the problem lies in what Oracle will do with MySQL, if the purchase is approved by the EC.

With that Michael “Monty” Widenius, the creator of MySQL, is asking you urgently to help save MySQL from Oracle’s clutches. He is asking us to write the EC, and demand Oracle to change the terms for MySQL or give other guarantees to the users.

He has compiled a list of steps that one can take in order to help with this cause.

What I want to ask you to do (until 2009-12-19):

- Forward this email to everyone that you know is using MySQL or Open Source/free software and to all email list where you know there are people present that use or care about MySQL and open source (please check first that this email hasn’t been sent there before)
- Alternatively send emails with information about this and tell them to read http://monty-says.blogspot.com/2009/12/help-saving-mysql.html
- Add links on your web site to http://monty-says.blogspot.com/2009/12/help-saving-mysql.html with the text “We are using MySQL, help save it”, for the duration of the next two week.
- Blog about this (feel free to include this text or just link to my blog)
- Call by phone (don’t contact by email, this is urgent) your boss or VP and ask him to read this email and send a letter to the EC commission ASAP!
- If you don’t have anyone to contact above, send an email to the EC!

You can find the body of the email by visiting his blog post “Help saving MySQL

Contact the European Commission and help save MySQL.

I’ve recently discovered a nice plug-in for jQuery that mimics the “Feedback” tab that most webapp sites are using these days. I’ve downloaded the plug-in from theodin.co.uk, in hopes to use it for a quick request quote form for my web design company. I’ve modified it quite a bit to make it more secure. I went ahead and used jQuery FormSubmit plug-in to send the data to a php file that also does some validation on the data being inputted by the user.

Everything was setup and working, but I was doing my development on Ubuntu and running Mozilla Firefox 3.5. So, when I went to test it on Windows XP Internet Explorer 7 and 8. I noticed that the tab would not behave the same as it does on Firefox or Google Chrome.

Contactable jQuery Plugin on IE8

Contactable jQuery Plugin on IE8


Read the rest of this entry »

iBuldings.com PHP 5.3 Migrating Guide

Cal Evans has been kind enough to provide the PHP World with a guide to migrating to PHP 5.3, which can be found in the TechPortal.

Make sure to read the Release Announcement as you familiarize yourself with the new features, and improvements.

As PHP developers download and start testing the biggest change to the language in 7 years, many are wondering not about Santa’s bag full of new toys for them to use in building tomorrow’s applications but about the changes in the language that will affect yesterday’s applications.

The following is a distillation of the PHP 5.3 migration guide. We only cover those items most likely to affect legacy 5.x code.

The full guide can be found in the iBuildings Blog

PHP 5.3 Released

It is finally here. PHP 5.3 has been released and like we mentioned before (PHP Namespaces Is Not Years Away, Now In PHP 5.3). It supports Namespaces.

Orlando PHP User Group

Finally, there is a PHP User Group for Orlando. We will be meeting April 22nd for our first meeting. If you are in the Orlando area please be sure to visit. The first meeting will be dedicated to the different frameworks available to PHP. For more information, go to orlandophp.org.

This article is outdated, for more information on PHP Namespaces please check the PHP Manual.

Namespaces have been around for quite a while in Object Oriented programming with languages such Java. Basically, for those of you who have not used them, it means that you can create a context or package for a set of variables, functions and classes to prevent same named objects from different packages to conflict.

<?php

/* PHP Namespace sample */
namespace Project::Sample;

class Foo {
  function bar () {
    echo "Test namespace function";
  }
}

// since Project::Sample is the current namespace
$foo = new Foo();

// or using the full namespace
$foo = new Project::Sample::Foo();

// or using the use keyword
use Project::Sample as Sample

$foo = new Sample::Foo();

$foo->bar(); // Prints: Test namespace function
?>

Read the rest of this entry »

Joe Lencioni over at Shifting Pixel, has written a post about the easy to use image resizing script. It’s a really simple script that you use by specifying the parameters in the src part of the img tag.

The major advantage of this script is that it allows me to resize and crop any image on my website without touching the actual image or writing any code.

Try the script yourself, and if you can improve on it let him know by leaving him a comment.
A ridiculously easy-to-use PHP script for resizing images the smart way.

Hasin Hayder from Developer Tutorials wrote this neat post about using debug_backtrace. It could help you debug your code more efficiently and save you hours of dumping variables and testing functions, not to mention saving you from pulling your hair out. I myself used it a couple of times when writing class files and such, it helps you read the code a little better too. Go ahead and check out his post and leave a comment.

Debugging PHP code using debug_backtrace

What better way to connect and share with others about your experiences in web development, than a community event that includes:

  • Programming
  • Geeks
  • Robots
  • More Programming
  • Even More Robots
  • Podcasting
  • RSS Feeds
  • Photoshop
  • Whiskey (not free)
  • and More!

Well, for those of us that live in and near Orlando, FL this event is called BarCampOrlando.

BarCampOrlando

It will take place Downtown Orlando on April 5th – 6th at the Wall Street Plaza. Registration is FREE, but it is highly recommended that you give a demo, a session or help with one at the event. Both Jamal and myself will be attending both days and look forward to seeing more of you there.

http://www.barcamporlando.org/