LEARN PHP BASICS: Beginner's Guide For Coding by J TAM
Author:J TAM [TAM, J]
Language: eng
Format: azw3
Published: 2020-05-09T16:00:00+00:00
Let's take an example illustrating the spaceship operator in PHP.
<html>
<head>
<title>PHP <=> Operator or Spaceship Operator</title>
</head>
<body>
<?php
print (5 <=> 5);
echo "<br/>";
print (3 <=> 5);
echo "<br/>";
print (5 <=>3);
echo "<hr/>";
print ("C" <=> "C");
echo "<br/>";
print ("A" <=> "C");
echo "<br/>";
print ("C" <=> "A");
echo "<hr/>";
?>
</body>
</html>
PHP ?? or Coalescing Operator
The ?? operator in PHP is introduced in its 7th version, that is, PHP 7.
In PHP ?? or Coalescing operator, if the first operand of this operator is set then it returns its first operand, otherwise second operand will be returned by this operator.
Here is an example that demonstrates PHP Coalescing or ?? operator.
<html>
<head>
<title>PHP ?? Operator or Coalescing Operator</title>
</head>
<body>
<?php
$firstname = "Codes";
$lastname = "Cracker";
$fullname = $_POST['name'] ?? 'name is empty';
echo $fullname;
echo "<hr/>";
$name = $firstname ?? "firstname is not initialized";
echo $name;
echo "<hr/>";
$name = $surname ?? "surname is undefined";
echo $name;
echo "<hr/>";
$name = $fullname ?? "fullname is set previously";
echo $fullname;
?>
</body>
</html>
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Access | Data Mining |
Data Modeling & Design | Data Processing |
Data Warehousing | MySQL |
Oracle | Other Databases |
Relational Databases | SQL |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6652)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6625)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6500)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6287)
Driving Data Quality with Data Contracts by Andrew Jones(6240)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6006)
Learning SQL by Alan Beaulieu(5984)
Weapons of Math Destruction by Cathy O'Neil(5774)
Big Data Analysis with Python by Ivan Marin(5316)
Data Engineering with dbt by Roberto Zagni(4319)
Solidity Programming Essentials by Ritesh Modi(3968)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3818)
Pandas Cookbook by Theodore Petrou(3530)
Blockchain Basics by Daniel Drescher(3292)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2899)
Feature Store for Machine Learning by Jayanth Kumar M J(2807)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2790)
Mastering Python for Finance by Unknown(2741)
