NETTİM
← Kod Sonuçlarına Dön
PHP SQL sorguları Sınıflar Fonksiyonlar Lisans: Belirtilmemis

PHP: Constants - Manual

PHP: Constants - Manual • PHP — SQL sorguları, Sınıflar, Fonksiyonlar. Sınıflar: Constants. Fonksiyonlar: getMinValue, getMaxValue. SQL sorgusu içerir.
Sınırlı Önizleme Politikası: Bu kodun açık kaynak lisansı doğrulanamadığı için telif kuralları gereği yalnızca kısa önizlemesi gösterilmektedir. Tam kod için orijinal kaynağa gidin ↗.
/manual/en/language.constants.php • PHP
11/14/2016 - note updated by sobak
-----

CONSTANTS and PHP Class Definitions

Using "define('MY_VAR', 'default value')" INSIDE a class definition does not work as expected. You have to use the PHP keyword 'const' and initialize it with a scalar value -- boolean, int, float, string (or array in PHP 5.6+) -- right away.

<?php

define('MIN_VALUE', '0.0');   // RIGHT - Works OUTSIDE of a class definition.
define('MAX_VALUE', '1.0');   // RIGHT - Works OUTSIDE of a class definition.

//const MIN_VALUE = 0.0;         RIGHT - Works both INSIDE and OUTSIDE of a class definition.
//const MAX_VALUE = 1.0;         RIGHT - Works both INSIDE and OUTSIDE of a class definition.

class Constants
{
  //define('MIN_VALUE', '0.0');  WRONG - Works OUTSIDE of a class definition.
  //define('MAX_VALUE', '1.0');  WRONG - Works OUTSIDE of a class definition.

  const MIN_VALUE = 0.0;      // RIGHT - Works INSIDE of a class definition.
  const MAX_VALUE = 1.0;      // RIGHT - Works INSIDE of a class definition.

  public static function getMinValue()
  {
    return self::MIN_VALUE;
  }

  public static function getMaxValue()
  {
    return self::MAX_VALUE;
  }
}

?>

Tespit Edilen SQL Sorguları

with a scalar value -- boolean, int, float, string (or array in PHP 5.6+) -- right away.
with the parentheses).

Benzer Kod Örnekleri

PHP — edit.php
PHP • SQL sorguları
PHP — delete.php
PHP • SQL sorguları
PHP — add.php
PHP • SQL sorguları
PHP — CDOBind.php
PHP • SQL sorguları