Belrick, nice with the ',' seperation but the deep indent takes to much time in notepad and would force horizontal scrolling in most forums? The brace on the function line makes it harder for us dislexics to pair them off. Brace as in two pistols. Not to mention the forcing of scrolling in the forums again but that is what indenting does. I like to do without it.
I use netbeans IDE and selecting one brace highlights the matched pair.
Also netbeans auto lines up each new line. SO if top line is 1 tab in a carraige return brings it to start point one tab in.
Netbeans also allows you to set the number of spaces for each tab.
You can also select multiple lines and tab as one.
Takes literally seconds of extra coding but saves minutes++ when debugging and MCA
Also
When outputting HTML i like to indent to show element relationships.
Right on NogDog, I still preffer this though, ie. no indent and space between statements.
PHP Code:
<?php
function foo(PDO $pdo, $bar, $time)
{
$sql = "
SELECT
foo_id,
foo_name,
foo_timestamp
FROM foo.bar
WHERE
foo_name = :bar
AND
foo_timestamp > :time
";
$stmt = $pdo->prepare($sql);
if($stmt == false)
{
throw new Exception("Prepare failed: ".print_r($pdo->errorInfo()));
}
$stmt->bindParam(':bar', $bar, PDO::PARAM_STR);
$stmt->bindParam(':time', $time, PDO::PARAM_STR);
if($stmt->execute() == false)
{
throw new Exception("Query failed: ".print_r($stmt->errorInfo()));
}
return $stmt->fetchAll();
}
I know it may sound pathetic but i cannot handle your code.
Im like a woman with OCD walking into a messy house just itching to clean up the place!
"OK, time to break out the mops, the tabs and carriage returns!
One other thing to do is instead of having lots of little functions. (say a class setters) i like to merge them into one function then seperate out each 'setter' by a switch. I do this because i end up with a lot of functions anyway normally.
eg:
PHP Code:
function set_property($property,$value){
switch ($property){
case "HEIGHT":
$this->height = $value;
break;
One other thing to do is instead of having lots of little functions. (say a class setters) i like to merge them into one function then seperate out each 'setter' by a switch. I do this because i end up with a lot of functions anyway normally.
eg:
PHP Code:
function set_property($property,$value){
switch ($property){
case "HEIGHT":
$this->height = $value;
break;
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
For me a good PHP programmer means someone who is efficient - who can solve problems and build quality web based software quickly and in a way that allows easier maintenance and extending of the program.
I never understand why people still use this considering the free alternatives. It's like seeing somebody use an abacus to do math.
+1 (Though an expert abacus user can do basic math calculations very quickly, mind you -- a better analogy might be calculating cube roots with just pencil and paper. )
I can't imagine doing any serious coding without, at a minimum, built-in syntax-checking and auto-indent. And when you add things like syntax highlighting, auto-complete, and so forth; why would anyone use Notepad by choice?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I'm a NetBeans user coming from TextWrangler. While all I really "needed" was syntax highlighting, having the automatic error checking made my development go so much faster. And of course the auto complete is kinda nice too. The thing that really sold me on NetBeans though, was the built in SVN and Database management. Doesn't get much better than that.
Yeah NogDog and ScottyBoy, I guess that I wanted to ask that this wouldn't be offensive enough to prohibit advice from forum administrators or advisers as that is the bottom line in my opinion.
Example?
PHP Code:
$sql = '
SELECT username //not:user_name
FROM pcusers //not:pc_users or camel case
WHERE userid=2
';
The PHP code box already contains the Indent? The opening and closing are separated from the statement so that I can distinguish between the two?
I know this is a short example and script pages seem to go on for ever but at present I'm the only one who reads mine other than the questions I post in the forums. I don't crunch them any more and I've decided to use this style in the last two months, specifically for posting to forums. I was born dyslexic and had a teacher who caught that fact when I was in Junior high school so I was soon there after awarded the 'Reading' prize? The main point again, being not to offend any would be help? Of course the teacher couldn't fix my A.D.D. (attention deficit disorder) which we now believe is the true cause for rampant use of 'IeSpell'.
Last edited by THEFOOL; 05-11-2012 at 11:57 AM.
Reason: The PHP code box already contains the Indent?
Bookmarks