All browsers do not display empty strings properly in a table cell. Part of the table cell
borders disappear when attempting to display an empty string. What phpLens does is to automatically insert a
non-breaking space " " into the cell. If you want to manipulate the values in a cell that may
potentially have an empty cell, you have to check for the empty string. This example shows how you
go about checking for an empty string.
In this example: If {country} is not entered into the database, display {country} as "unknown".
This is a Demo. You can not change anything for security reasons.
PHPLens: 4.9.2 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 5.2.17 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Notes
What we want is to check if the value in {Country} is a non-breaking space.
If it is, we replace the value with "unknown". Otherwise, we display {Country}
We have used the ternary conditional operator in PHP for this.
Powerlens setting for {country}
The non-breaking space is a special variable in phpLens known as {nbsp}.
Ternary conditional operator
For those of you unfamiliar with the ternary conditional operator, the explanation for this is below:
The ternary conditional operator functions as follows:
$first ? $second : $third
If the value of the first subexpression is true (non-zero),
then the second subexpression is evaluated, and that is the result of the conditional expression.
Otherwise, the third subexpression is evaluated, and that is the value.
You can read more on this in php.net's
online documentation.
Why we can't use " " in Powerlens
When you use phpLens to generate source code, phpLens uses the semi-colon character ";"
to separate fields in phpLens properties. Therefore, you cannot enter a semi-colon in Powerlens.
E.g.
You cannot enter the following in Powerlens:
As a workaround, phpLens has a variable called {nbsp} to represent " ". In the next version of phpLens,
we will make available another variable called {semicolon} which will provide you with another way to handle
special characters.