There is a word from the MSYQL database displayed in {$ goods.phone_1} On the HTML page, everything is fine, the value is visible and in Javascript is also assigned, but not in php. Implementation in any convenient way!

If i do like this

<? $string = "{$goods.phone_1}"; if (isset($string[1])){?> 

determines how full it seems to me because of $

 <? $string = "{$goods.phone_1}"; if (isset($string[1])){?> <div class="letter_teh2">{$goods.phone_1|escape}</div></span> <?}else{?><?}?> 

All this is necessary for. If {$ goods.phone_1} is not empty then show <span class = "letter_teh"> {$ lang.phone_1}: <div class = "letter_teh2"> {$ goods.phone_1 | escape} </ div> </ span>

All the code of the pilgrim ----------------------------------------------- -----------------

 {include file=header.html} {include file=top.html} <div id="content"> <div id="left"> {include file=left.html} </div> <div id="right"> {include file=goodsinfo.html} <a name="module"> <ul class="user_menu"> <div class="ornament1"></div> <div class="ornament2"></div> <li><a class="normal" href="{url app=goods&id=$goods.goods_id}#module"><span>Описание товара</span></a></li> <li><a class="active" href="{url app=goods&act=comments&id=$goods.goods_id}#module"><span>Основные характеристики</span></a></li> </ul> <!-- Вывод информации с модуля Основные характеристики --> <!--/*-------------Мобильные устройства-----------------------------------*/ --> <span class="letter_teh">{$lang.phone_1}: <div class="letter_teh2">{$goods.phone_1|escape}</div></span> <span class="letter_teh">{$lang.phone_2}: <div class="letter_teh2">{$goods.phone_2|escape}</div></span> <span class="letter_teh">{$lang.phone_3}: <div class="letter_teh2">{$goods.phone_3|escape}</div></span> <span class="letter_teh">{$lang.phone_4}: <div class="letter_teh2">{$goods.phone_4|escape}</div></span> <span class="letter_teh">{$lang.phone_5}: <div class="letter_teh2">{$goods.phone_5|escape}</div></span> <span class="letter_teh">{$lang.phone_6}: <div class="letter_teh2">{$goods.phone_6|escape}</div></span> <span class="letter_teh">{$lang.phone_7}: <div class="letter_teh2">{$goods.phone_7|escape}</div></span> <span class="letter_teh">{$lang.phone_8}: <div class="letter_teh2">{$goods.phone_8|escape}</div></span> <span class="letter_teh">{$lang.phone_9}: <div class="letter_teh2">{$goods.phone_9|escape}</div></span> <span class="letter_teh">{$lang.phone_10}: <div class="letter_teh2">{$goods.phone_10|escape}</div></span> <span class="letter_teh">{$lang.phone_11}: <div class="letter_teh2">{$goods.phone_11|escape}</div></span> <span class="letter_teh">{$lang.phone_12}: <div class="letter_teh2">{$goods.phone_12|escape}</div></span> <span class="letter_teh">{$lang.phone_13}: <div class="letter_teh2">{$goods.phone_13|escape}</div></span> <span class="letter_teh">{$lang.phone_14}: <div class="letter_teh2">{$goods.phone_14|escape}</div></span> <span class="letter_teh">{$lang.phone_15}: <div class="letter_teh2">{$goods.phone_15|escape}</div></span> <span class="letter_teh">{$lang.phone_16}: <div class="letter_teh2">{$goods.phone_16|escape}</div></span> <span class="letter_teh">{$lang.phone_17}: <div class="letter_teh2">{$goods.phone_17|escape}</div></span> <span class="letter_teh">{$lang.phone_18}: <div class="letter_teh2">{$goods.phone_18|escape}</div></span> <span class="letter_teh">{$lang.phone_19}: <div class="letter_teh2">{$goods.phone_19|escape}</div></span> <span class="letter_teh">{$lang.phone_20}: <div class="letter_teh2">{$goods.phone_20|escape}</div></span> <span class="letter_teh">{$lang.phone_21}: <div class="letter_teh2">{$goods.phone_21|escape}</div></span> <span class="letter_teh">{$lang.phone_22}: <div class="letter_teh2">{$goods.phone_22|escape}</div></span> <span class="letter_teh">{$lang.phone_23}: <div class="letter_teh2">{$goods.phone_23|escape}</div></span> <span class="letter_teh">{$lang.phone_24}: <div class="letter_teh2">{$goods.phone_24|escape}</div></span> <span class="letter_teh">{$lang.phone_25}: <div class="letter_teh2">{$goods.phone_25|escape}</div></span> <span class="letter_teh">{$lang.phone_26}: <div class="letter_teh2">{$goods.phone_26|escape}</div></span> <span class="letter_teh">{$lang.phone_27}: <div class="letter_teh2">{$goods.phone_27|escape}</div></span> <span class="letter_teh">{$lang.phone_28}: <div class="letter_teh2">{$goods.phone_28|escape}</div></span> <span class="letter_teh">{$lang.phone_29}: <div class="letter_teh2">{$goods.phone_29|escape}</div></span> <span class="letter_teh">{$lang.phone_30}: <div class="letter_teh2">{$goods.phone_30|escape}</div></span> <span class="letter_teh">{$lang.phone_31}: <div class="letter_teh2">{$goods.phone_31|escape}</div></span> <span class="letter_teh">{$lang.phone_32}: <div class="letter_teh2">{$goods.phone_32|escape}</div></span> <span class="letter_teh">{$lang.phone_33}: <div class="letter_teh2">{$goods.phone_33|escape}</div></span> <span class="letter_teh">{$lang.phone_34}: <div class="letter_teh2">{$goods.phone_34|escape}</div></span> <span class="letter_teh">{$lang.phone_35}: <div class="letter_teh2">{$goods.phone_35|escape}</div></span> <span class="letter_teh">{$lang.phone_36}: <div class="letter_teh2">{$goods.phone_36|escape}</div></span> <span class="letter_teh">{$lang.phone_37}: <div class="letter_teh2">{$goods.phone_37|escape}</div></span> <span class="letter_teh">{$lang.phone_38}: <div class="letter_teh2">{$goods.phone_38|escape}</div></span> <span class="letter_teh">{$lang.phone_39}: <div class="letter_teh2">{$goods.phone_39|escape}</div></span> <span class="letter_teh">{$lang.phone_40}: <div class="letter_teh2">{$goods.phone_40|escape}</div></span> <span class="letter_teh">{$lang.phone_41}: <div class="letter_teh2">{$goods.phone_41|escape}</div></span> <span class="letter_teh">{$lang.phone_42}: <div class="letter_teh2">{$goods.phone_42|escape}</div></span> <span class="letter_teh">{$lang.phone_43}: <div class="letter_teh2">{$goods.phone_43|escape}</div></span> <span class="letter_teh">{$lang.phone_44}: <div class="letter_teh2">{$goods.phone_44|escape}</div></span> <span class="letter_teh">{$lang.phone_45}: <div class="letter_teh2">{$goods.phone_45|escape}</div></span> <span class="letter_teh">{$lang.phone_46}: <div class="letter_teh2">{$goods.phone_46|escape}</div></span> <span class="letter_teh">{$lang.phone_47}: <div class="letter_teh2">{$goods.phone_47|escape}</div></span> <span class="letter_teh">{$lang.phone_48}: <div class="letter_teh2">{$goods.phone_48|escape}</div></span> <span class="letter_teh">{$lang.phone_49}: <div class="letter_teh2">{$goods.phone_49|escape}</div></span> <span class="letter_teh">{$lang.phone_50}: <div class="letter_teh2">{$goods.phone_50|escape}</div></span> <dt><a href="{$app_data.app_url}">{$app_data.app_name}</a></dt> <dd>{$item}</dd> </dl> <!--{/if}--> <div class="clear"></div> </div> <div class="clear"></div> </div> {include file=footer.html} 
  • With $ string = '{$ goods.phone_1}' Parse error: $ TEXT = $ string = "{\ $ goods.phone_1}"; The same - d_i_m99
  • Interested in why <? $ string = "{$ goods.phone_1}"; in this form does not assign a value to a variable. The answer about the design arrived. - d_i_m99
  • Because it is {$ goods.phone_1} to parse your template engine and generates some kind of php code - avengerweb

2 answers 2

 {if $goods.phone_1|escape|strlen > 2} <div class="letter_teh2">{$goods.phone_1|escape}</div></span> {/if} 

Something like that, what template do you use?

    http://tsya.ru

     $string = "{\$goods.phone_1}"; $string = '{$goods.phone_1}'; 

    isset ($ string [1])

    Uhhhh, this is a very strange construction. It is easier to at least write if ($string) , if I understand its purpose correctly.

    • @Fike, isset ($ string [1]) check if there is a second character in the line. Imagine that string -> a kind of array consisting of char elements. - avengerweb
    • Yesterday I showed TSU how to check for the presence of a symbol ... - avengerweb
    • @avengerweb, if I didn’t know this, I’d have to bury me, and as the epitaph I would choose three single more or less adequate lines of my code. The author is obviously interested not in the first character, but in the presence of content in the string. - etki
    • @ d_i_m99, you do not assign a variable in this way. As I understand you have a template engine, most likely - smarty ... - avengerweb
    • @Fike, I have a slice of doubt in you, if ($ string) the condition is not met, if the variable $ string == false or == null in any other case (whether there are characters or not and the variable is defined) the condition is met. As for isset ($ string [1]), it will indicate if there is a character in the string, and hence the output is empty or not. It happens balls rolls are rolled ... :) - avengerweb