How is a constant defined in a PHP script?

by cristobal , in category: Technology , a year ago

How is a constant defined in a PHP script?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by bailey_conroy , a year ago

Defining a Constant in PHP

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