Solved

PHP Defined Constants.  Names and Usage Examples

Posted on 2012-04-06
4
427 Views
Last Modified: 2013-11-13
Is there any online reference that tells us the meaning and usage of the PHP defined constants?  For example among many hundreds) what is the expected usage of CURLE_FTP_WEIRD_SERVER_REPLY?  Or CAL_JEWISH_ADD_ALAFIM_GERESH? Or INF or TYPEOTHER?  I can find mention of some of these things in various places in www.php.net but no consolidated descriptions.  So far the best I can come up with is this, which is OK for a search, but not very convenient for a study tool.
Please see: http://laprbass.com/RAY_get_defined_constants.php
<?php // RAY_get_defined_constants.php
error_reporting(E_ALL);

// SHOW ALL THE CONSTANTS -- EXPECT A LOT OF OUTPUT
// SEE: http://php.net/manual/en/function.get-defined-constants.php

// DEFINE ONE OF OUR OWN
define('ZZZZ_FOO', 'bar');

$c = get_defined_constants();
$n = number_format(count($c));
ksort($c);

// MAKE CLICKABLE LINKS
foreach ($c as $k => $v)
{
    $a
    = '<a'
    . ' target="_blank"'
    . ' href="http://php.net/results.php?l=en&p=wholesite&q='
    . urlencode($k)
    . '">'
    . $k
    . '</a>'
    ;
    $c[$a] = $v;
    unset($c[$k]);
}

// SHOW THE WORK PRODUCT
echo "<pre>";
echo "THERE ARE $n PREDEFINED PHP CONSTANTS";
echo PHP_EOL;
print_r($c);

Open in new window

Thanks, ~Ray
0
Comment
Question by:Ray Paseur
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37815990
Ray, I don't know but I have a suggestion.  I was curious so I did some searches, starting with the Jewish constant.  I suspect you already know it has to do with Jewish dates and that their calendar starts before Jesus.  All I figured out that Geresh seems to be an apostrophe and Gershayim appears to be a quotation mark.  http://en.wikipedia.org/wiki/Gershayim

My suggestion for the Jewish constants is to ask a new question with the constants in the header.  Hopefully, someone with a Hebrew education will be able to shed some light on the standards for the Jewish calendar.  BTW, Jews are starting Passover at sunset tonight.  (So, in some parts of the world, it's started.  Might be some time before you get a reply if you wait.)

My thought is the usage is obvious to someone with a (good) Hebrew education and thus the explanation in the manual is lacking.  (I could be wrong, however.)  In any event, interesting question.
0
 
LVL 108

Author Comment

by:Ray Paseur
ID: 37816214
Thanks, Hugh.  The Jewish date constant is just one example (there are a lot of Israeli guys who have contributed to PHP).  To clarify, my question is a little more broad.  I found 1,612 defined constants in my PHP installation.  I am kind of thinking that since there is a function reference in the php.net site, would there be a constant reference?  I can't find one.  It may not exist, but if it does I would sure like to see it!  Cheers, ~Ray
0
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 total points
ID: 37817015
Ray,

I agree.  I'd like to see a constant reference too.

You posed a really good question.  

Hugh
0
 
LVL 108

Author Comment

by:Ray Paseur
ID: 37833990
Hugh:  Don't spend all your points in one place!  I'm closing this out - looks like it doesn't exist.  All the best, ~Ray
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
A short article about problems I had with the new location API and permissions in Marshmallow
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now