PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Your code could be a bit neater and consistent (I wouldn't even mention it though if you hadn't asked). The way you've laid out your if/else statement is a) slightly inconsistent and b) not 100% conforming to pre-existing practices.
One practice is almost exactly like you've got the else clause set up - with the opening bracket on the same line as the condition:
Most important is consistency. It's very difficult to read large blocks of code with no consistent style. As long as code has a consistent style, it's OK to read.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Yeah the way i see is that if they input the url incorrectly then its going to produce an error. Asin validate the url i think you mean check that theres a www and a . etc things like that?
I have already set the value of the input box to the right format(value="www.").
I like the way you wrote it very simple but i think sometimes its best to ask people who have been coding a while how they would have done it and then compare.
Yeah i think it broke the formatting when i copied paste... in an if statement or loop... i always put a { and } on a new line with one tab from the previous {
I know above code could be written in one if statement or even another way... just to show you where i place my brackets. Is this bad practice?. I find it easier to read this way with each block in more of a section.
it appears you are trying to test if the url is valid/working.. meaby a http HEAD request might be more appropriate..
I believe there is a pear package, HTTP_* package that can do this for you...
I dont feel I would learn from using pear pre made scripts.
I feel that to be copy and paste, thats ok if you have deadlines to meet I think but I am just learning to code. All i would need to do to return the headers is use curl.
I might code a little script that returns the header for a domain and get your views on it.
I hope you guys dont mind me asking is this code is good or crap.