Link to home
Start Free TrialLog in
Avatar of weikelbob
weikelbobFlag for United States of America

asked on

Getting Ready for a PHP position.

I've got an interview with an IT firm for a PHP/Java position.

I want to be ready.

What areas of PHP should I be fluent in? How can I prepare? I'm an intermediate with PHP.

SOLUTION
Avatar of John Kawakami
John Kawakami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of weikelbob

ASKER

That's a good idea.

What else?

I'd like to know the areas of PHP which are most usually expected for a PHP programming job.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What string manipulation aspects do I need to know?

Also, should I open a separate question for each area I need to talk to you guys about?
Well, string manipulation is one of the strengths of PHP. THere are loads of functions (as you know) that can make life easy for you. It's just a matter of combining those functions in a proper way.
It's not a matter of knowing all the ins and outs of every string function, what params they require etc. It's more a matter of knowing what function you could use for a certain task. (the phpdocs will provide you with the ins and outs at all times :)

So, knowing how to use the phpdocs is vital to being an inventive programmer.

Asking what string manipulation aspect you need to know is a very hard question to answer. It's better to read through the phpdocs on the matter:
http://php.net/strings

You're already an intermediate PHP programmer, so you've been working with string for quite some time. You will know what kind of string manipulation you use most of the times. It won't be much different in a different working environment.

I can give you some pointers though:
- Don't use regex unless necessary. I find that a lot of people use it for very simple tasks that could do with i.e. str_replace().
- Make sure you do skill yourself provoundly in regex though, since they're vital for more complicated string manipulation
- Don't get stuck on an idea, if you can't solve a problem with the string functions you're using, distance yourself from the it for a while and think of other methods to solve the problem (but that goes for all programming problems I guess :) This might sound like advice that everyone knows already, but I had to learn it...

Good luck,
TeRReF
TeRReF,

Thank you. That synopsis is exactly what I was looking for.

Now what is optimization of code?  (Let me know if I should open a separate question.)

Well, there's always good and bad approaches to problems. Ones that take a lot of time and or resources and ones that don't.
I realize that sometimes it's more work to do things the 'right' way, especially when under time pressure. But ALWAYS keep opmimization in the back of your head when developping.
To give you some examples:
Using file_get_contents() instead of fopen(), fread()/fgets() and fclose() is easier. It will be a good method if the file is small, but when you work with huge files it means that the whole file has to be loaded into memory. When you use fopen(), etc. this will not happen and you will be able to handle the file 1 line at a time...

Another example is DB result sets. Same story, a lot of people and the whole resultset to an array first and then start to process it. A better way (usually) is to retrieve the resultset 1 row at a time and process it in the same loop...

These are just pointers and you will have to analyze every situation on it's own since they're all different. Saying these sorts of things during the interview, will help you a lot though. It will make them realize you are aware.

So, during the interview it's not all about knowledge about the language aspects, equally important is how you use it...
Oh, another important part of optimization is query performance.
"IF they're using PHP5 especially, OOP"

What are you referring to here?
In PHP5, Object Oriented Programming capabilities matured (more or less). In other words, since then it's possible to do some serious OOP programming in PHP. As soon as it was available, I started to use it since it makes reusability of code easier.
OK.

So how do you create a class in PHP5?  (Only a brief answer is needed)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<?php

        class blah {
                public $member;
                //other members (vars)

                function __construct($var) {
                      $this->member = $var
                }

                 // other methods that define the class' functionality
        }

         $object = new blah('value');

?>
I suggest that you don't even bother trying to fool the interviewer.  Just fess up to how much PHP you know.  If you know Java well, it won't be a big issue -- they'll probably assume you can be taught.
You're right jk2001,

I don't want to fool them.

I'm seeing that there is a lot of PHP I don't know.

Perhaps to finish this off, you guys could give me some links to advanced tutorials.

Bob

I learned a lot of PHP by downloading canned scripts and reading the code.  A lot of it wasn't that good, though.  Managing a codebase for some project is a great way to get good, very fast.  If you know someone who needs a CMS-backed website, maybe you can volunteer to install and configure the system, and add a few features.

The PHP.net site has a lot of good examples, too.  Look at the comments.
"I learned a lot of PHP by downloading canned scripts and reading the code. "

Good idea. Do you have some direction or links as to where to come across the right scripts?

Here are the ones I've studied, with a few star ranks indicating code quality/interesting-ness:

HORDE/IMP **** (out of 5)
Drupal ***
PhpMyAdmin ****
PHPMailer **

That's the open source stuff.  I've also used HiveMail, vBulletin, aeDating, GUSTMail.  They vary in quality, too.  I usually look for stuff at hotscripts.com and freshmeat.net.  Also, there is a lot of code at PHPClasses.com, php.net, and in the PEAR repository.

Most established scripts are written for PHP4, while most of the new frameworks rely on PHP5.
Avatar of AmigoJack
AmigoJack

sidenote: thx jk2001 for hotscripts.com - from that i found a wonderful WYSIWYG editor for free which works on MSIE, OPER and FIRE :) thx alot
@AmigoJack
Can you share the URL for that editor with us? :)
@TeRReF: http://www.openwebware.com/products/openwysiwyg/
its a very good enhancement (i.e.) for a html-allowed phpBB. users without knowledge of html can nearly work with it like they know it from ms word - and skilled users can always toggle between html- and text-view. of course, this one is also not a perfect one, but the best solution ive seen so far (which also cares for all major browsers)
@AmigoJack
Thanks! Looks very good.
jk2001,

Can you give me a link to specific pieces of, for example, HORDE/IMP code? it's a big project and I'm not sure where to start.

Yes, all those are big projects.   Here's the URL for horde.

http://www.horde.org/imp/

For smaller scripts, I suggest hotscripts.  Some of those require payment to deploy, but you can still look at the code to learn things.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ellandrd,

Thanks! I just spent 5 minutes in that link and I've already learned a lot.

Question: When do you use OO PHP in a project?
yes its a good site isnt it.  i first came across this site a few months ago while searching for a PHP script and i noticed your question in the list of open questions and thought - i know the perfect PHP website...  im glad its helping you learn more and prepare better for interview!

>>When do you use OO PHP in a project?

Very good question Bob! Well I suppose the whole point of OOP is to think in terms of objects - real things.  This
means nouns which have a state/data and verbs which cause them to perform actions.

GUI programming is one place where OO is handy and obvious.  Having a
Window class which draws itself makes alot sense.  A list of windows which your
program owns is then quite simple.

Here are 2 nice discussions related to OOP that will help you understand more:

When to use and when not to use OOP
(http://www.sitepoint.com/forums/showthread.php?t=182925&page=1)

Maximize PHP apps using OOP techniques
(http://builder.com.com/5100-6371-5054846.html)

Good Luck
Ellandrd
Thanks everyone,

Bob