Jump to content

PHP Shorthand


monkey64

Recommended Posts

I'm a newbie and I'm trying to simplify my code.  Instead of:

echo "var is ";
if ($var < 0)
echo "negative";
else
echo "positive"; 

 

I'm using this:

echo "var is ".($var < 0 ? "negative" : "positive");

 

But, in this example, I want to simplify it in the same manner.

 

if($finance > '2000') {
$loan = $finance - 2000;
$deposit = $loan;	
} else {		
	$loan = $finance;
	$deposit = $finance / 10; // 10% of Discount Price
	}

 

Thing is, in each condition, I have two variables.  Can it be simplified?

Link to comment
https://forums.phpfreaks.com/topic/170376-php-shorthand/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.