How is a constant defined in a PHP script?

Member

cristobal

by cristobal , in category: Technology , a month ago

How is a constant defined in a PHP script?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by bailey_conroy , a month ago

Defining a Constant in PHP

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