Jump to content

[SOLVED] What is better? "space" or "tab"...


web_master

Recommended Posts

Hi,

 

I think this will be a question of experince.

 

Of a time when I begin to write the PHP scripts I do a changes in a style of a writing. Mean at the begin I uses a spaces us a distancer but for now I use the tabs. (not everywhere).

 

<?php

// Reload == 2
if($_REQUEST['reload']<SPACE>==<SPACE>"2") {

// Insert into dBase
$query_return=mysql_query("INSERT INTO `vendegkonyv`<SPACE>(
<TAB>	`vendegkonyv_nev`,
	`vendegkonyv_varos`,
	`vendegkonyv_orszag`,
	`vendegkonyv_txt`,
	`vendegkonyv_datum`
?>

 

Can somebody tell me is some difference in this two writing styles?

 

---------------------------

 

The other thing is maybe a same differences.

 

This is a simple example:

<?php
$query_return = mysql_query("SELECT * FROM `vendegkonyv` WHERE `vendegkonyv_id` = ' " . $_POST['value'] . " ' ");
?>

Up is at end of line: apostrof, quote, dot, POST, dot, quote, apostrof

 

<?php
$query_return = mysql_query("SELECT * FROM `vendegkonyv` WHERE `vendegkonyv_id` = '$_POST['value']'");
?>

Up here is at end of line: apostrof, POST, apostrof.

 

Is some difference or maybe is there some other way of use?

 

thanx

 

T

Link to comment
Share on other sites

The last question: It's the same thing, but it's better to do the last code cause it's more readable where the variable is colored different. (And you have to validate input to mysql ;))

 

I didn't understand the first one. But

<?php mysql_query("INSERT INTO `table` VALUES('value1', 'value2')"); ?>

and

<?php mysql_query("INSERT INTO `table`
				VALUES('value1', 
				'value2')"); 
?>

is the same thing.

Link to comment
Share on other sites

I regularly use tabs, but I do also use spaces when aligning the text sometimes.

I would normally use tabs and spaces in the example i used above:

<?php mysql_query("INSERT INTO `table`
	   VALUES('value1', // Double tabs and three spaces
	   'value2')"); // Double tabs and three spaces
?>

 

But the spaces, breaks and tabs work great around each other  ;)

 

Edit: Just make it most readable by using the possible highlights.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.