Author Topic: ?:  (Read 146 times)

bmorton

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
?:
« on: January 26, 2012, 10:39:50 PM »
I'm very new to php so I'm sure this is pretty basic.  I need to translate the following into a else-if statement.

PHP Code: [Select]
<?php
 $ch 
100 + (($a $b) ? $a $b) * 15;
?> 


$a and $b can any interger

I just can't get my head around this.

Any help would be great.

Cheers
Brad
« Last Edit: January 28, 2012, 08:58:19 AM by jSherz »

Sarthak Patel

  • Senior Member
  • ****
  • Posts: 368
  • Karma: +6/-0
    • View Profile
Re: ?:
« Reply #1 on: January 27, 2012, 12:35:53 AM »
Quote
hi use below code instead of your current code.
PHP Code: [Select]

//use this code
$a=50$b=60// $a & $b are integer values.
 
if($a $b)
 {
 
	
$re $a;
 }
 else
 {
 
	
$re $b;
 }
echo 
$ch 100+$re*15;

I hope this will helpful for you.
Reply your feedback.
~~SR~~

bmorton

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: ?:
« Reply #2 on: January 28, 2012, 02:05:29 PM »
Would this do the same thing?
PHP Code: [Select]
$a 10;
$b 5;

if (
$a $b){
	
echo 
$ch 100 $a 15;
}
else {
	
echo 
$ch 100 $b 15;
}
?> 
« Last Edit: January 29, 2012, 11:15:07 AM by jSherz »

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 528
  • Karma: +5/-0
    • View Profile
Re: ?:
« Reply #3 on: January 28, 2012, 09:00:58 PM »
If you get rid of the 'echo' part, yes.

Sarthak Patel

  • Senior Member
  • ****
  • Posts: 368
  • Karma: +6/-0
    • View Profile
Re: ?:
« Reply #4 on: January 29, 2012, 11:45:50 PM »
Quote
Yes, your newly posted code is doing same thing as my code.

~~SR~~