Author Topic: [Problem] echo $number works fine, setvar displays nothing  (Read 755 times)

0 Members and 1 Guest are viewing this topic.

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
[Problem] echo $number works fine, setvar displays nothing
on: Tue, 03. December 2002 - 19:04:42
Perhaps I miss something, but this behavior seems strange to me:

Code: [Select]

$number = 2 - 2;

echo $number;



displays 0 like it should be.

Code: [Select]

$number = 2 - 2;

$tmpl-setvar'number', $number;



displays nothing.

Code: [Select]

$number = 2 - 2;

$tmpl-setvar'number', $number;



works fine again.

It's working this way, but why echo and setvar work differently?

Regards,
Claus

---
Note:
First encountered in:
Code: [Select]

if $successes_a = $successes_b



$netto = $successes_a - $successes_b;

$winner = A;



else



$netto = $successes_b - $successes_a;

$winner = B;





$tmpl-setvar'netto', $netto; // $netto==0 would display nothing instead of 0

$tmpl-setvar'winner', $winner;


Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
[Problem] echo $number works fine, setvar displays nothing
Reply #1 on: Tue, 03. December 2002 - 19:07:52
By the way ...

$tmpl->setvar('number', 0);

does not work either.

Regards,
Claus

releasedj

  • Guest
[Problem] echo $number works fine, setvar displays nothing
Reply #2 on: Tue, 03. December 2002 - 19:45:19
Was this happening within a Loop?

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
[Problem] echo $number works fine, setvar displays nothing
Reply #3 on: Tue, 03. December 2002 - 23:37:29
No, normal code.

Does it not occur in your enviroment?

Then I will look after my version.

But I think it is 3-0-10.

releasedj

  • Guest
[Problem] echo $number works fine, setvar displays nothing
Reply #4 on: Wed, 04. December 2002 - 12:18:04
I see where the problem is.

If you need this urgently you can change the setVar function in vlibTemplate.php yourself.
In the 'else' section you'll see at the end off the if statement it says:
Code: [Select]

if preg_match'/^A-Za-z_+A-Za-z0-9_*$/', $k && $v != null



.. you just need to change the " && $v != null" to " && $v !== null" so it reads:
Code: [Select]

if preg_match'/^A-Za-z_+A-Za-z0-9_*$/', $k && $v !== null



I'll fix this in the next version of vLIB, which should be out soon.


Regards,

Kelvin