Finding a new blogging system
December 23, 2005
So over the past few months I have been debating on a new blogging software as WordPress doesn’t exactly tickle my feet… I ran into a pretty good blogging software not to long ago called LifeType, while just past version 1.0 they have a fairly nice architecture almost purely object oriented. What is so nice about that is how you can actually utilize it to work as an API. The documentation is fairly interesting causing me to wonder exactly how they are doing it.
There is some odd behavior with the custom fields although that was just me implementing them utilizing the objects as an API and trashing the frontend. However this project is well thought out and beats writing my own as I am far too picky about my code to ever get it done in a reasonable time. However in the future after I finish off one of my many coding projects I have started I will probably end up writing one. I will probably wait for 5.1 to become a bit more stable and adopted in the community before I start a project like that.
Currently I try to write everything with php 4.4.x, php 5.0.x and 5.1.x to work all the same, however writing for compatibility between all of the versions sometimes can cause some issues. I guess I will see what I can create out of the LifeType blogging platform this weekend on my nice weekend off.
Writing for Future PHP6 Compatibility
December 3, 2005
With the PHP 6 Developers Meeting Notes out I finally took a while to go and read through them and figure out what is the best way to move forward and start writing code that will be compatible not only for 4x and 5x but continue on though 6x. While sometimes it is not possible to keep everything being deprecated if you are using 4 or 5.0 there are some recommendations that you might want to follow.
Register Globals
If you are currently using them STOP! Register Globals is not a very good thing to have turned on by default anyway, most developers I have seen do not understand either the impact of them being on or how to combat them. These will be removed in PHP 6 anyhow.
Magic Quotes
Magic quotes are going to be removed from PHP6. So if you are using them you might want to try and code against them. A good way you might want to check against them is by the following:
if (version_compare(phpversion(), '6', '>=')) {
function get_magic_quotes_gpc(){
return false;
}
}
if (get_magic_quotes_gpc()) {
stripslashes(); //your input
}
Call Time Pass by Reference
Call time pass by reference is going to be removed… So all of you that are currently initiating your objects with the reference operator should stop doing it, although it will be an E_STRICT error, you might still want to only use it if you must!
$var =& new stdObject(); //current object reference
$var = new stdObject(); //just do this instead ![]()
zend.ze1_compatibility_mode
Do not run in this mode. It will give a core error and halt execution if you use it in PHP6. If your PHP4 applications do not run without that setting on, fix it to run with it off and continue on.
Long Globals (HTTP_*_VARS)
These will be removed and if you are not currently using $_POST and $_GET why not?!
Case Sensitivity
They are starting to move away from the case insensitivity of functions and classes. Try to use all lowercase, also it makes it much nicer to know if you are using a custom function that way!
Dynamic breaks
They are removing support for dynamic breaks. So for those of you who do: break $myvar; Find another way and clean up that messy code!
Database Extensions/Objects
Move to PDO as soon as you can (PHP 5.1). The plan is to slowly move Non-PDO database extensions out of the core. It would just be best to migrate to those as soon as you can.
ereg
If you use ereg for your regular expressions move to preg since it is faster and also ereg will be moved out of the PHP core.
Strings and {}
If you are currently accessing the letters of a string by $str{1} you should move to []. Yes the manual told you to use {} but now they are going against that because people want to use []. So they are going to throw away {} in PHP6 while it is deprecated in 5.1.
@ini_set
Since the @ operator is currently very slow they are removing support for it to work on ini_set. Might want to check to see if you can use ini_set for certain operations before trying it!
Open and Closing Tags
The and also < % %> will be removed. Also < ? is starting to be looked down upon. Might just want to start going with for everything.
Conclusions
That is about all I thought was worth mentioning when talking about future compatibility. If you are still using php4 to php5 compatibility, you might want to think about removing PHP4 in the coming months since there is already 5.0 and 5.1 versions out. Yes I know you guys do not like to give up your old ways but it is time to move on.
What I actually thought about doing was writing versions strictly for php5.1 or 6.0 and then having a cvs to tag and branch them out. So I actually have versions for 4.3, 4.4, 5.0, 5.1 and then a head revision for whatever comes next. Just a few thoughts on how to manage it.



