Just a quickie: From Tim of Sacratee there is a post on Jatecblog about Making use of Object Oriented PHP which provides a good simple example of how to use OOP in PHP5 to build a module-based system.
Category: Net: Techy: PHP
Posts about the PHP programming language
Making the web has a couple of articles about how to make PHP scripts run faster and more efficiently. Checking the lists show I’m already doing quite a few of the items listed:
- Multiple arguments with echo (i.e. using “,” instead of “.”)
- I don’t currently do this, but it’s only 0.396% faster
- Reduce function calls (i.e. find out the size of an array before a loop, not in the “for statement”)
- I do do this, but not as much as I should – especially with a 54.095% difference!
- Avoid using variables if they aren’t needed and unset them once you’ve finished with them
- I try to do this, but there doesn’t appear (from the site) to be any speed penalties in not doing this.
- Use single quotes (instead of double quotes – ” )
- I’ve done this for ages as I knew PHP didn’t have to parse the string – but I didn’t know it was only a 0.696% speed difference.
- str_replace() vs ereg_replace() and preg_replace()
- I tend to use preg_replace instead of ereg_replace anyway, and I’m aware that using any sort of regular expressions is slow. Therefore I do try and use str_replace instead – after all, it’s a 59.224% saving in speed!
Wake Up Later has a list of 10 Absolute “Nos!” for Freelances which include (with my comments):
- Can you show me a mock-up to help us choose a designer/developer?
When I worked for a web hosting company, we did waste a lot of time doing web site designs for people as “mock ups” and a few times we did see the ideas “recycled” in their finished design even though they hadn’t paid us. The percentage of “mock ups to completed projects” was quite low as well – meaning wasted time. Oh – and the number of people that said “I don’t like that mock up, can you do another”… Grrr… On the plus side, I’ve just realised that an insurance company that I wrote the billing system for nearly a year ago whilst at my previous employer is still in use, despite the pet insurance company having very little (if anything) to do with my previous employer now. Go me! - Can you give us a discount rate?
Am I the only person in the world that thinks “The price you see is the price you pay”? You don’t expect Tescos or Sainsburys to “haggle” the price of your food do you? Well, don’t expect web designers, programmers, hosting companies etc to do the same! - Will you register and host my site?
I slightly disagree with this one – the designer will be able to register the domain name and host it with a third party: but as long as they make it totally clear they are just performing the “payment side” of things and the client needs to contact the appropriate company if there is any “non-design/code” issues then it should be ok. - Can you copy this site?
Straight coping is a “no-no”, but trying to get a “similar look” to a site isn’t too bad. I.e. if you are doing a shopping cart: do you like the look of Amazon, Tesco, Play will help speed the design work along. - Can I pay for my e-commerce site from my website sales?
A big no from me here as well! If the designer/freelancer says to the customer “I’ll do it cheaper if you’ll split the sales” that means the designer/freelancer thinks the customer has a very good ideas. However, if the customers asks for it – then the customer must think it’s not such a good idea and hence doesn’t really want to risk their money. - I have a great idea. Do you want to…?
To me, this’ll depend on the circumstances. If they came to me (as a programmer) and said they’d like to partner for me and they can supply the design and backend content, and I’ve got to figure out how to get the content online and handle the promotion of it – then I may do. However, if it’s a case of “I want a shop to sell books via Amazon. I can design the site, can you do the back end…” then IMHO they won’t be contributing that much to the project. If they added their own book reviews then that’s another kettle of fish. - Do you have an IM account?
I’ve practically given up on IM clients (such as Yahoo, AOL, MSN Messenger and ICQ) mainly because of the Spam (Yahoo especially) and the fact that when I am logged in I’m not always available to chat (away from the machine) or I’m busy working on something. I tend to have my PC on a “always ready” state (i.e. text edit, browsers etc already loaded and positioned) so opening and closing Trillian (which I used to use to log me into all the different networks) will be an extra thing to remember… - Can I just pay the whole amount when it’s done?
- Is there any way you could get this done tonight or this weekend?
- Can I be sure you won’t use this work in anything else?
I tend to do the same as Samuel (the other of the original post) in that “(1) their code has utilized code from other projects which I haven’t charged them for, and (2) I will probably use code from their project on other projects, and (3) they own the code and implementation of the project (finished website), but not the actual code pieces (login system, image uploader, etc.). I pride myself in productivity and speed, and I need to use other code all the time to accomplish this.”. However, in most circumstances I do “copy my own code” but in a slightly different manner – so the “jist” of the code may be the same, it’ll be slightly different for each implmentation.
I’ve already blogged about 13 facts about Friday the 13th which is paraskevidekatriaphobia or just triskaidekaphobia if you only fear the number 13. But Friday the 13th of July 2007 will go down as a “notable date” for some web developers – it’s the day that the End of Life of PHP4 was announced.
PHP4 as a programming language will become discontinued on the 31st of December this year – so if you’ve got an essential program which depends on PHP4 – contact the developers to make it PHP5 compatible now (after all, PHP5 has been out 3 years and they are now working on PHP6!). Ok, some people will be stuck (if I remember correctly, osCommerce doesn’t work brilliantly on PHP5 but I may be mistaken), but unfortunately that’s life…