PHP as Keyword

P
PHP case Keyword
PHP and Keyword

In this article, you will learn how to use AS keyword in PHP.

he as keyword in PHP is used by the foreach loop to establish which variables contain the key and value of an element.

The as keyword in PHP can also be used by namespaces and traits to give them an alias.

examples of the AS keyword

Example 1. In this example, we Use as in a foreach loop.

<?php
$list = [1, 2, 3, 4];
foreach($list as $item) {
  echo $item;
  echo "<br>";
}
?>
PHP case Keyword
PHP and Keyword

Tutor Network

Share this

Learn PHP from A to Z