Wednesday 15 June 2011

conditional operator - Php ternary statement -


Hi I was trying to understand your code recently, so shopping cart was watching the pageinator class, so I could build my own pageinator in the following line of code, it looks like a threesome statement but written in a way that I have never seen before. I google it but I do not know what Google is, can someone tell me how it works and what is called it, so I can do a search for it and learn more.

Return ($ output? '& Lt; div class = "'. $ This- & gt; style_link." "& Gt; $. $ Output. '& Lt; / div & Gt; ':' ')' & lt; Div square = '' $ This- & gt; Style_reets. ' '& Gt;' . Sprintoff ($ AT-> - $ total)? (($ Page - 1) * $ range) + 1: 0, (($ page - 1) * $ range) & gt; ($ Total - $ range)) $ total: (($ ($ page - 1) * $ range) + $ limit), $ total, $ num_pages) '& lt; / Div & gt; ';

Just tell me if there is enough code to go to Andrew

This is called a conditional operator and I abuse it about it.

  if (a == b) c = d; If the consultant operators are low, they may be useful in reducing the other. Other C = E; // can be written as: c = a == b? Day;  

The given code can be written as:

  return ($ output? '& Lt; div class = "'. $ This - & gt; style_links '' & gt; '$ output.' & Lt; / div & gt; ':' ').' & Lt; div class = ''. $ This- & gt; style_resets. '& Gt;' Sprintoff ($ AT -> - $ total)? (($ Page - 1) * $ range) + 1: 0, (($ page - 1) * $ range) & gt; ($ total - $ range)) $ Total: ('$ page-1) * $ border) + $ limit), $ total, $ num_pages' '; / div & gt;';  

Equivalent:

  if ($ output) $ str = '& lt; div class = "' $ This- & gt; Style_links '' & gt; '. $ Output '& lt; / Div & gt; '; Else $ str = ''; $ Str = '& Lt; Div class = "'. $ This- & gt; style_first.' '; If ($ total) $ first = (($ page - 1) * $ range) + 1; and $ before = 0; if $ ($ Page - 1) * $ range) & gt; ($ total - $ range)) $ second = $ total; and $ sec = ((($ page - 1) * $ range) + $ limit); $ $ Str. = '
/ Div>

No comments:

Post a Comment