Ternary Operator in PHP

Francois

Why this code do not want to work ?

<?php
$currMonth='01';
?>

<a class="btn btn-xs btn-<?php ($currMonth=='01') ? 'primary' : 'default'; ?>-outline">

My output is empty:

<a class="btn btn-xs btn--outline">

Thanks.

pdu

It is working. It is just not outputting something because you haven't told php to do so. Change <?php to e.g. <?php echo.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

understading the ternary operator in php

From Dev

evaluation of ternary operator in php

From Dev

PHP Ternary Operator Misunderstanding?

From Dev

evaluation of ternary operator in php

From Java

How to write a PHP ternary operator

From Dev

PHP ternary operator syntax error

From Dev

Understanding PHP's ternary operator

From Dev

ternary operator in php with echo value

From Dev

Understanding PHP's ternary operator

From Dev

PHP ternary operator syntax error

From Dev

Conditional ternary operator malfunctions (PHP)

From Dev

Ternary operator inside calculation PHP

From Dev

Ternary operator in PHP generated table

From Java

PHP ternary operator vs null coalescing operator

From Dev

How to use continue keyword in a ternary operator in php

From Dev

convert some lines of php statement into ternary operator

From Dev

Is there a PHP like short version of the ternary operator in Java?

From Dev

Implement inline ternary operator in embedded HTML in PHP

From Dev

How to use php ternary operator in the parameter of a function?

From Dev

How to use continue keyword in a ternary operator in php

From Dev

PHP selected dynamic option with Ternary Operator

From Dev

convert some lines of php statement into ternary operator

From Dev

Can logical operator be used with in ternary operators in PHP

From Dev

PHP inline statement using ternary logic operator "?:"

From Dev

+ operator in a ternary operator

From Dev

Ruby ternary operator (or) or operator

From Dev

Ternary operator and increment operator

From Dev

Ternary Operator(Elvis Operator) ?:

From Dev

Ternary operator with "OR" operator not working?

Related Related

HotTag

Archive