News:

SMF - Just Installed!

Main Menu

<?PHP,,,, ?>

Started by KingSparta, Dec 07, 2023, 04:55 PM

Previous topic - Next topic

KingSparta

<?

echo str_word_count("Hello world!");
 
?>

KingSparta

+   Addition   $x + $y   Sum of $x and $y   
-   Subtraction   $x - $y   Difference of $x and $y   
*   Multiplication   $x * $y   Product of $x and $y   
/   Division   $x / $y   Quotient of $x and $y   
%   Modulus   $x % $y   Remainder of $x divided by $y   
**   Exponentiation   $x ** $y   Result of raising $x to the $y'th power

KingSparta

<!DOCTYPE html>
<html>
<body>

<?php
echo strpos("Hello world!", "world");
?>
 
</body>
</html>

KingSparta

<?php
$t = date("H");

if ($t < "20") {
  echo "Have a good day!";
} else {
  echo "Have a good night!";
}
?>

KingSparta

<?php
$t = date("H");

if ($t < "10") {
  echo "Have a good morning!";
} elseif ($t < "20") {
  echo "Have a good day!";
} else {
  echo "Have a good night!";
}
?>

KingSparta

<?php
     echo strpos("Hello world!", "world");
?>

POS 6

KingSparta

Replace String
The PHP str_replace() function replaces some characters with some other characters in a string.

Example
Replace the text "World" with "Dolly":

$x = "Hello World!";
echo str_replace("World", "Dolly", $x);