How is a constant defined in a PHP script?

by cristobal , in category: Technology , 4 years ago

How is a constant defined in a PHP script?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by bailey_conroy , 4 years ago

Defining a Constant in PHP

1
2
<?php
  define('CONSTANT_NAME',value);  
by dion.waelchi , 4 years ago

@cristobal You can also define constant in PHP like this:

1
2
3
4
<?php
  const TEST = 'test';
  // and then call it like this
  echo self::TEST;

Related Threads:

How to increase the execution time of a PHP script ?
How to Create a Composer Package in 2025?
What Is Php Error Handling in 2025?
What is difference Between PHP 5 and 7?
What is namespaces in PHP?
What is list in PHP?