Solved

PHP Defined Constants.  Names and Usage Examples

Posted on 2012-04-06
4
430 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 109

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 109

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
A short article about problems I had with the new location API and permissions in Marshmallow
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 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

17 Experts available now in Live!

Get 1:1 Help Now