How to use define to define constants in php

墨辰丷
Release: 2023-03-30 15:54:01
Original
2604 people have browsed it

This article mainly introduces how to use define to define constants in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

The details are as follows:

<?php
/*
 * define
 * */
 /*第3个参数:
 * false -- 对大小写敏感(默认)
 * true -- 对大小写不敏感
 * */
 define("pai",3.14);
 define ("name","LiLei",true);
 function testfor($x) {
  for($a=$x;$a<=12;$a++) {
    echo "现在是$a 点:";
    if($a<9) {
      echo "敲代码";
      echo name;
    } else {
      echo "睡觉";
      echo pai;
    }
    echo "<br />";
  }
 }
 testfor(10);
?>
Copy after login

The running results are as follows:

It is 10 o'clock now: sleeping 3.14
It is 11 o'clock now: sleeping 3.14
It’s 12 o’clock now: sleep 3.14

Summary: The above is the entire content of this article, I hope it will be helpful to everyone’s study.

Related recommendations:

PHP’s more secure password encryption mechanism Bcrypt graphic and text explanation

php achieves batch implementation Method of uploading data to the database

PHP method of using Socket to obtain the SSL certificate and public key of the website

The above is the detailed content of How to use define to define constants in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!