Jek Jek - 2 years ago 79
PHP Question

PHP meaning of '//'

I've been converting some code from other languages (that are using algorithms) and adding them into PHP to some class code.

I came across some code that did the following line: (Python)

decNumber = decNumber // 2

I thought that it meant divide by two, but the outcome of adding this to my code was not as expected.

If this doesn't mean
in PHP form then is there a PHP equivalent for this?

Answer Source

In PHP // means single line comment. The characters after // won't be executed.

You can use type casting in PHP for achieving the same. Below code will give you integer quotient.

$decNumber = 3;
$decNumber = (int)($decNumber / 2) ;
echo $decNumber;



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download