Where can I get a complete list of variables that PHP automatically makes available to my script by looking at the output of the phpinfo() function? - superglobals

I'm using PHP 7.2.3 on my machine that runs on Windows 10.
I've installed PHP using latest version of XAMPP.
I come across following text from PHP Manual :
$_SERVER is just one variable that PHP automatically makes available
to you. A list can be seen in the Reserved Variables section of the
manual or you can get a complete list of them by looking at the output
of the phpinfo() function.
In the above text from PHP manual it has been clearly said that I can see the complete list of such variables which PHP automatically makes available to my script.
When I observed the output of phpinfo(); I could only see the entire array of $_SERVER[] superglobal variable. I couldn't see any other such predefined superglobal variables in the output of phpinfo();
Can I say this is a mistake in PHP manual?
Or can I say the manual is saying the thing rightly but I'm not able to get it and see the other predefined superglobal variables?
Please someone help me out in this regard.
Thank You.

There is a function called get_defined_vars() which does exactly what you want.
There are even more of them:
get_defined_constants - Gets all constants
get_defined_functions - Gets all functions
get_defined_vars - Gets all variables
get_declared_classes - Gets all declared classes
I couldn't see any other such predefined superglobal variables in the output
Screw what i said about this earlier. You are right, doc says
phpinfo() is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data.
It should be noted, that you find GET, POST and COOKIE in $_REQUEST and not in their array respectivly.
If you only want to get the super globals from phpinfo, try following:
phpinfo(INFO_VARIABLES);

Related

Saving API as environment variable (for setting up monkeylearn in R)

I would like to use the named entity recognition functions in the monkeylearn package in R.
As part of the setting up process, we need to do the following:
"To get an API key for MonkeyLearn, register at http://monkeylearn.com/. Note that MonkeyLearn supports registration through GitHub, which makes the registration process really easy. For ease of use, save your API key as an environment variable as described at http://stat545.com/bit003_api-key-env-var.html. You might also want to use the usethis::edit_r_environ() function to modify .Renviron.
All functions of the package will conveniently look for your API key using Sys.getenv("MONKEYLEARN_KEY") so if your API key is an environment variable called “MONKEYLEARN_KEY” you don’t need to input it manually.
Please also create a “MONKEYLEARN_PLAN” environment variable indicating whether your Monkeylearn plan is “free”, “team”, “business” or “custom”. If you do not indicate it by default it will be “free” with a message. If your plan is “custom” you’ll need a third environment variable “MONKEYLEARN_RATE” indicating the maximum amount of requests per minute that you can make to the API. If you do not indicate it, by default it will be 120 with a message."
I've gotten the API key, but as a layman, I couldn't understand the guide on saving the api key as environment variable. Could anyone provide a step by step guide for Windows please?
Thank you.
monkeylearn maintainer here, sorry for the unclear docs.
It means you need to add two lines in an R startup file called .Renviron.
MONKEYLEARN_KEY="blablablayourkey"
MONKEYLEARN_PLAN="free"
The last line of .Renviron has to be an empty line.
To open .Renviron to edit it, you can use usethis::edit_r_environ(). After adding the two lines with your key and plan, don't forget to restart R.
Read more about startup files in general in this resource.
I hope this helps. Note that I don't look up Stack Overflow very often as opposed to rOpenSci's forum

Get R warnings and errors in english

I'd like R to show me debug messages in english instead that in my locale (Italian). Having messages in italians makes it difficult to look on the internet for help on debugging. Not to mention that sometimes translations are sloppy at least.
How can revert R to use only the original version of messages and not to translate them?
thanks!
You want to set the "LANGUAGE" environment variable (see relevant documentation):
Sys.setenv(LANGUAGE='en')
To do this, though, you need to have message translations installed (which I believe are optional on at least some platforms).

Drupal WebForms Data Structure Reference?

I am relatively new to Drupal. We have a site and I've been asked to jump in and make some changes. I'm working on customizing the output of the Webforms module. I'm having trouble doing so because I can't seem to find a reference to the various data structures Webforms uses.
For example, I need to change something in a preprocess hook. Passed into the hook is a structure called $variables. I can see that attributes are being added to the piece I want to change, so I know I'm in the right hook. What I want to do is add something to the text. But I can't figure out where in $variables the text is so I can change it.
I'm sure what I need to change is in there, but I can't seem to get at it. All the documentation I've found on the web is either "paste this code in" or assumes you know the data structures.
So:
1. Is there a reference anywhere to these structures? $variables is one. $submission, $components are others. There are probably more. I know their contents vary widely with the specific webform, but looking for a general reference.
2. How can I see the contents of one of the structures from inside a hook? I've tried a lot of things, but no luck. Would be great to either have it output to the Apache log, or show up on the screen, something...
Any help would be greatly appreciated. It feels like there's real power here, but I can't get at it because I'm missing some basics.
I would say you need to install 2 modules to figure out what is going on...
First Devel, allowing you to use the dmp function. This will output a whole array to the message area.
And then my new favorite module, Search Krumo.
A webform is generated from large array of data and finding the bit that is relevant to you can often be difficult just looking though the dmp output. Search Krumo puts a search box in the message area allowing you to search for any instances of a string in the whole array structure. When you've found the bit that is relevant it also lets you copy the path to that array element so you can easily modify values buried deep in multi-arrays.
EDIT:
If you don't want the output on the screen but would rather log it then use Devel Debug Log. Very useful for debugging ajax requests etc.
If you just need to log simple strings not whole arrays then the dd function is useful combined with: tail -f /tmp/drupal_debug.txt assuming you have SSH access.

t() function does't add the string to the translation interface

i use customfiel php code inside one of my views to translate a string since 2.x of views is bad at localization. i use the following php code:
echo t('Watch Video');
but the string does not appear in the "translate interface" section.
thanks for your help.
lukas
The accepted answer is wrong, as the localization script is not scanning anything. The string is registered in the translate interface as soon as it gets passed through the t() function for the first time in the non-standard language.
Therefore, for translation it doesn't matter if the code you are writing is eval'd (interpreted from the database) or exists in the source. Obviously good practice would be to keep code in files where it belongs.
This blog post describes what needs to be done to get your strings into the translate interface.
The localisation database is built by scanning the source code, looking for instances of the t() function (and Drupal.t() in Javascript).
If the code in question has been entered into a text box in the Drupal admin area, then it isn't in the source code, so it won't be picked up by the localisation process.
For this reason (and others), you should put as little code as possible into the admin text boxes. There is usually an alternative way to achieve the same thing, but even if there isn't, you should reduce the code to a minimum -- best practice would be to have nothing there except a single line function call: have it call a function, and write the function code in your module or theme. That way it will be parsed when you run the localisation.

autoit: what's the difference between inetget and inetread

I see there are two functions in autoit to download files from the internet: inetget and inetread.
What's the difference between the two? The only difference I see is that inetGet has more options and is therefore better.
Inetget() supports background download (your script will continue its work while your file will keep downloading) and returns you a handle you can use with Inetgetinfo(). Inetread can do nothing of this.
Read the manual carefully, everything is described there. :)
By the way, AutoIT's doc is very good to me.
There IS a big difference! InetRead() directly returns the downloaded string, so you can assign it to variable while InetGet needs a filename parameter to store into, so if you periodically get some data it may be better to use inetread instead to prevent hdd usage.

Resources