Title here
Summary here
PHP has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
<?php
// Strings, which can be concatenated with the '.' operator.
echo "php" . "lang" . PHP_EOL;
// Integers and floats.
echo "1+1 = " . (1 + 1) . PHP_EOL;
echo "7.0/3.0 = " . (7.0 / 3.0) . PHP_EOL;
// Booleans, with boolean operators as you'd expect.
echo (true && false) ? "true" : "false";
echo PHP_EOL;
echo (true || false) ? "true" : "false";
echo PHP_EOL;
echo (!true) ? "true" : "false";
echo PHP_EOL;To run the program, save it as values.php and use the PHP interpreter:
$ php values.php
phplang
1+1 = 2
7.0/3.0 = 2.3333333333333
false
true
falseIn this PHP example:
echo function to print output, which is similar to fmt.Println in the original example.. operator instead of +.&&, ||, and ! for logical AND, OR, and NOT operations, respectively, just like in the original example.?:) to convert boolean results to strings for output, as echo doesn’t automatically convert booleans to strings.PHP_EOL is used for line breaks, which is equivalent to \n in many other languages.This example demonstrates basic value types in PHP and how to perform simple operations with them.
Comments powered by Disqus