PHP code example of eloquent / constance

1. Go to this page and download the library: Download eloquent/constance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eloquent / constance example snippets


use Eloquent\Constance\AbstractClassConstant;

final class PdoAttribute extends AbstractClassConstant
{
    /**
     * The class to inspect for constants.
     */
    const CONSTANCE_CLASS = 'PDO';

    /**
     * The expression used to match constant names that should be 

$attribute = PdoAttribute::memberByValue(PDO::ATTR_ERRMODE);

echo $attribute->name();          // outputs 'ATTR_ERRMODE'
echo $attribute->qualifiedName(); // outputs 'PDO::ATTR_ERRMODE'

class MyConnection
{
    public function setAttribute(PdoAttribute $attribute, $value)
    {
        // ...
    }
}

$connection = new MyConnection;
$connection->setAttribute(PdoAttribute::ATTR_AUTOCOMMIT(), true);
$connection->setAttribute(PdoAttribute::ATTR_PERSISTENT(), false);

use Eloquent\Constance\AbstractGlobalConstant;

final class ErrorLevel extends AbstractGlobalConstant
{
    /**
     * The expression used to match constant names that should be 

$members = ErrorLevel::membersByBitmask(E_ALL);

$members = ErrorLevel::membersExcludedByBitmask(E_ALL);

$members = array(ErrorLevel::E_NOTICE(), ErrorLevel::E_DEPRECATED());
$bitmask = ErrorLevel::membersToBitmask($members);

$isStrictByDefault = ErrorLevel::E_STRICT()->valueMatchesBitmask(E_ALL);