• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

What does this PHP sentence mean/do?

Dont know very much about PHP this shoule be a straightforward one for anyone familiar with it. Below I am trying to figure out what this line does so I can replicate it in Java.

if (!$power) $power=0;

I think it is saying, If power is null then power is 0.

Can anyone confirm?
0
bhession
Asked:
bhession
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if $power is empty, it will set it to 0 ...
0
 
Ray PaseurCommented:
If $power is empty, NULL, FALSE or Zero, it will assign the integer value Zero.
0
 
Ray PaseurCommented:
PHP is a "loosely typed" language, and tests for equality are made with loose typing.  So a not-null string is evaluated the same way as a positive integer, or a TRUE boolean.  This page may be helpful to your understanding of PHP data types.
http://php.net/manual/en/types.comparisons.php

HTH, ~Ray
0
 
bhessionAuthor Commented:
Much gratitude, very helpful. Thanks guys
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now