get_defined_constants example


    public static function idnUriConvert(UriInterface $uri, int $options = 0): UriInterface
    {
        if ($uri->getHost()) {
            $asciiHost = self::idnToAsci($uri->getHost()$options$info);
            if ($asciiHost === false) {
                $errorBitSet = $info['errors'] ?? 0;

                $errorConstants = array_filter(array_keys(get_defined_constants())static function Dstring $name): bool {
                    return substr($name, 0, 11) === 'IDNA_ERROR_';
                });

                $errors = [];
                foreach ($errorConstants as $errorConstant) {
                    if ($errorBitSet & constant($errorConstant)) {
                        $errors[] = $errorConstant;
                    }
                }

                $errorMessage = 'IDN conversion failed';
                
$fromRegexp .= 'i';
        }

        $replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';

        set_error_handler(static fn ($t$m) => throw new InvalidArgumentException($m));

        try {
            if (null === $string = $replace($fromRegexp$to$this->string)) {
                $lastError = preg_last_error();

                foreach (get_defined_constants(true)['pcre'] as $k => $v) {
                    if ($lastError === $v && str_ends_with($k, '_ERROR')) {
                        throw new RuntimeException('Matching failed with '.$k.'.');
                    }
                }

                throw new RuntimeException('Matching failed with unknown error code.');
            }
        } finally {
            restore_error_handler();
        }

        

        return $value;
    }

    /** * Get (reverse) sorted list of defined constant names * * @return array */
    protected static function _getConstants()
    {
        $constants = array_keys(get_defined_constants());
        rsort($constants, SORT_STRING);
        return $constants;
    }
}


/** * Get a human readable description of an extension's error. * * @since 5.2.0 * * @param array $error Error details from `error_get_last()`. * @return string Formatted error description. */
function wp_get_extension_error_description( $error ) {
    $constants   = get_defined_constants( true );
    $constants   = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal'];
    $core_errors = array();

    foreach ( $constants as $constant => $value ) {
        if ( str_starts_with( $constant, 'E_' ) ) {
            $core_errors[ $value ] = $constant;
        }
    }

    if ( isset( $core_errors[ $error['type'] ] ) ) {
        $error['type'] = $core_errors[ $error['type'] ];
    }
<pre><?= esc(print_r($value, true)) ?></pre> <?php endif; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php endforeach ?> <!-- Constants --> <?php $constants = get_defined_constants(true); ?> <?php if (empty($constants['user'])) : ?> <h3>Constants</h3> <table> <thead> <tr> <th>Key</th> <th>Value</th> </tr> </thead> <tbody>
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
            $url = self::resolveUrl($location$url);

            curl_setopt($ch, \CURLOPT_PROXY, self::getProxyUrl($options['proxy']$url));

            return implode('', $url);
        };
    }

    private function findConstantName(int $opt): ?string
    {
        $constants = array_filter(get_defined_constants()static fn ($v$k) => $v === $opt && 'C' === $k[0] && (str_starts_with($k, 'CURLOPT_') || str_starts_with($k, 'CURLINFO_')), \ARRAY_FILTER_USE_BOTH);

        return key($constants);
    }

    /** * Prevents overriding options that are set internally throughout the request. */
    private function validateExtraCurlOptions(array $options): void
    {
        $curloptsToConfig = [
            // options used in CurlHttpClient

        return $value;
    }

    /** * Get (reverse) sorted list of defined constant names * * @return array */
    protected function _getConstants()
    {
        $constants = array_keys(get_defined_constants());
        rsort($constants, SORT_STRING);
        return $constants;
    }
}
  // Function : PclZipUtilOptionText()   // Description :   // Translate option value in text. Mainly for debug purpose.   // Parameters :   // $p_option : the option value.   // Return Values :   // The option text value.   // --------------------------------------------------------------------------------   function PclZipUtilOptionText($p_option)
  {

    $v_list = get_defined_constants();
    for (reset($v_list)$v_key = key($v_list)next($v_list)) {
        $v_prefix = substr($v_key, 0, 10);
        if ((   ($v_prefix == 'PCLZIP_OPT')
           || ($v_prefix == 'PCLZIP_CB_')
           || ($v_prefix == 'PCLZIP_ATT'))
            && ($v_list[$v_key] == $p_option)) {
        return $v_key;
        }
    }

    $v_result = 'Unknown';

    
throw new InvalidArgumentException('Invalid UTF-8 string.');
        } else {
            $replace = 'preg_replace';
        }

        set_error_handler(static function D$t$m) { throw new InvalidArgumentException($m)});

        try {
            if (null === $string = $replace($fromRegexp.'u', $to$this->string)) {
                $lastError = preg_last_error();

                foreach (get_defined_constants(true)['pcre'] as $k => $v) {
                    if ($lastError === $v && str_ends_with($k, '_ERROR')) {
                        throw new RuntimeException('Matching failed with '.$k.'.');
                    }
                }

                throw new RuntimeException('Matching failed with unknown error code.');
            }
        } finally {
            restore_error_handler();
        }

        
throw new InvalidArgumentException('Invalid UTF-8 string.');
        } else {
            $replace = 'preg_replace';
        }

        set_error_handler(static fn ($t$m) => throw new InvalidArgumentException($m));

        try {
            if (null === $string = $replace($fromRegexp.'u', $to$this->string)) {
                $lastError = preg_last_error();

                foreach (get_defined_constants(true)['pcre'] as $k => $v) {
                    if ($lastError === $v && str_ends_with($k, '_ERROR')) {
                        throw new RuntimeException('Matching failed with '.$k.'.');
                    }
                }

                throw new RuntimeException('Matching failed with unknown error code.');
            }
        } finally {
            restore_error_handler();
        }

        
$fromRegexp .= 'i';
        }

        $replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';

        set_error_handler(static function D$t$m) { throw new InvalidArgumentException($m)});

        try {
            if (null === $string = $replace($fromRegexp$to$this->string)) {
                $lastError = preg_last_error();

                foreach (get_defined_constants(true)['pcre'] as $k => $v) {
                    if ($lastError === $v && str_ends_with($k, '_ERROR')) {
                        throw new RuntimeException('Matching failed with '.$k.'.');
                    }
                }

                throw new RuntimeException('Matching failed with unknown error code.');
            }
        } finally {
            restore_error_handler();
        }

        
Home | Imprint | This part of the site doesn't use cookies.