Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php functions

Status
Not open for further replies.

inusrat

Programmer
Feb 28, 2004
308
CA
I am new to PHP, I do not write php in function format. But I think lot of people do. Unless function needs to be used at different pages, what is the use of write php code in a function?

********
function total() {
return sprintf( "%.2f", $this->info[ 'quantity' ] * $this->info[ 'pricing' ] + $this->info[ 'setupcost' ] );
}

function display_line_item( $suffix=' )
{
// print some crap
}

}
**********

 
Placing PHP code in a function makes your code more readable, especially if you have a lot of lines of code to execute. For simple one-liners, this isn't much of an issue, unless you plan on reusing your code, like you said.

Nick Ruiz
Webmaster, DBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top