PHP Tutorial - Chapter 4 - PHP Strings & Constants (Khmer Language)

This video learn about PHP basic as Strings & Constants



1. Strings

- strlen
- str_word_count
- strrev
- strpos
- str_replace

Example:

<?php
echo strlen("Hello world!"); // outputs 12
echo str_word_count("Hello world!"); // outputs 2
echo strrev("Hello world!"); // outputs !dlrow olleH
echo strpos("Hello world!", "world"); // outputs 6
echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
?>

2. Constants

define(name, value, case-insensitive)

Parameters:

- name: Specifies the name of the constant
- value: Specifies the value of the constant
- case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false

Example 1: Use Default Case-Insensitive

<?php
define("GREETING", "Welcome to W3Schools.com!");
echo GREETING;
?>

Example 2: Use True Case-Insensitive

<?php
define("GREETING", "Welcome to W3Schools.com!", true);
echo greeting;
?>

Share this

Related Posts

Previous
Next Post »