Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smarty output to PHP Constant is it possible?

I got constant in PHP

This constant is written in Mysql

With Smarty i am doing output to HTML

Is it possible to output Smarty results to php not to HTML

<? {$CONSTANTS_RESULT[LOOP]} ?>

?

like image 717
Cameleon Avatar asked May 30 '11 21:05

Cameleon


People also ask

Can we use const in PHP?

A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before the constant name).

Can we define array as constant in PHP?

Yes, You can define an array as constant. From PHP 5.6 onwards, it is possible to define a constant as a scalar expression, and it is also possible to define an array constant. It is possible to define constants as a resource, but it should be avoided, as it can cause unexpected results.

Which is a correct way to declare constant in PHP?

A constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. If you have defined a constant, it can never be changed or undefined. To define a constant you have to use define() function and to retrieve the value of a constant, you have to simply specifying its name.

How can you declare variable and constant in PHP?

A constant can only be defined using define() function. It cannot be defined by any simple assignment. A variable can be defined by simple assignment (=) operator. There is no need to use the dollar ($) sign before constant during the assignment.


1 Answers

To access PHP constants in Smarty, you can use {$smarty.const.MY_CONSTANT} which is documented here.

like image 182
rcapote Avatar answered Sep 22 '22 00:09

rcapote