How is a constant defined in a PHP script?

by cristobal , in category: Technology , 3 years ago

How is a constant defined in a PHP script?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by bailey_conroy , 3 years ago

Defining a Constant in PHP

1
2
<?php
  define('CONSTANT_NAME',value);  
by dion.waelchi , 3 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;