Internal Variables for Use in Your Scripts
Grok Headline matches for Internal Variables for Use in Your Scripts
Edit the Scripts menu scripts with one
click
Edit the Scripts menu scripts with one
click
01/05/2005 10:36 PMFunkDaddy: "I wanted to look at the code of an AppleScript in the
Scripts Menu. Normally, I would have to do this by navigating to the
script in the Finder and opening it in Script Editor. But I took a
wild guess and Option-clicked on the script in the menu, and it opened
in Script Editor directly! This makes tweaking my frequently-used
scripts really easy."
Replacing Perl Scripts with PHP Scripts
Replacing Perl Scripts with PHP Scripts
11/26/2002 05:12 AMWith the introduction of version 4.2, PHP has started supporting a
new SAPI (Server Application Programming Interface) called CLI
(Command Line Interface). This facility was introduced to help
developers create small shell applications (scripts) with PHP. So, now
you can kiss Perl goodbye forever. -- Jayesh Jain
Hear hear. Thanks to my influence, other developers at Natsoft are
using PHP for their batch scripts too. Hmm maybe it is because they
report to me...
"zeldman.bang"
Use folder action scripts on a shell
scripts folder
Use folder action scripts on a shell
scripts folder
05/03/2004 10:44 AMRecently I purchase a book called "Wicked Cool Shell Scripts" by Dave
Taylor, and it is full of exactly that, cool shell scripts. Having not
done a whole lot of shell scripting before, I thought it would be good
to pick it up...
Application Variables with PHP
Application Variables with PHP
08/05/2002 10:44 PMOne of the most common feature requests that PHP developers ask for is
application variables. These are variables that are globally available
to all PHP scripts on a web server. There are currently several
implementations.
An Introduction to Variables
An Introduction to Variables
11/27/2002 09:47 PM
This is only for those who are new to php, or maybe programming
altogether. This won't 'enlighten' you, or make you 'one with
everything', but it should make you one with variables.
Variable Variables in PHP
Variable Variables in PHP
12/19/2002 10:43 PMVariable Variables in PHP
Well since it's late but I'm still grinding and I feel guilty for not
blogging much today, here's a special PHP Treat: A Variable Variable
Tutorial. Yes that's right. There is a feature in PHP called
"Variable Variables".
One of the issues that I had with implementing our Digibuy support was
our old friend and enemy: Parsing. This is such a fundamental thing
but there always seems to be a new wrinkle in it. In this case we had
an existing PHP script which did our registration calculations and was
expecting a certain set of variables. Now this code was fairly
complex and I didn't want to re-write it (much). Here's the input
data we had to parse:
author_id=BillBrown & author_password=HemosRules &
prod_sku=98079949999
With the exception that it had like 30 odd variables in it. Since my
code was expecting a series of variables I needed to parse this and
automatically create a series of variables like $author_id and
$author_password. Now if this data was being given to me by a URL
then it would be easy -- PHP could automatically do it or I could just
pull them out of $_REQUEST. But, instead, I had them going to me as
if they were a file. So ... How do you create a series of variables
on the fly?
Note: Yes I could have made an associative array but that wouldn't
have taught me anything, now would it ? I could also have gotten a
similar effect with the extract function but I found out about that
after this working. And if the code is working then ...
Well deep in the recesses of what I call a brain was a recollection of
"variable variables". I think I heard about this in a talk that
Rasmus gave although I can't honestly be sure. I do know that
whenever you need to do "meta" type tasks like this in a language, you
need to poke around the oddball features since that's usually where
they reside. What I do is look for the sections of the documentation
that I've never read. The idea behind a variable variable is simple:
interpret the value of a variable and make it into a variable itself.
I.e. the "variable variable" nomenclature.
Since php uses $ for indicating a variable they've chosen to use $$ to
make a variable variable. Let's say you have two variables, $part1
and $part2. If $part1 = "author_id" and $part2="HemosRules" how do I
get to $author_id = "HemosRules". Simple: $$part1 = $part2. Yup.
It's just that easy. Of course I did need to wrap it into a string
parsing loop. Here's the guts of it:
$strarray = explode("&",$input); foreach ($strarray as $stritem) {
$stritem = trim($stritem); $part1 = substr ( $stritem, 0, strpos
( $stritem,"=" ) ); $part2 = substr ( $stritem, strpos (
$stritem,"=" )+1, strlen ( $stritem ) ); #magic! $$ is a "variable
variable" i.e. it converts the value #in the variable into a
variable itself $$part1 = $part2; }
The way this works is an input string, $input, contains everything
that needs to be processed. First I explode this into an array using
"&" as the delimiter. Then I loop over the array with a foreach loop
creating a $part1 variable and a $part2 variable. Finally I just do
the magic $$part1 = $part2.
Here's the example Source Code.
Here's the working Example
Thanks again to my favorite Systems Administrator, Apokalyptik, for
showing me how to use PHP to generate code listings. Much easier than
pasting it into a blog entry.
More on Variable Variables from PHP.Net: [_Go_]
Variable Variables. A little confusing but definitely a frothy good
thing!
Predefined Variables
Predefined Variables
06/09/2004 03:40 PMPHP Application Variables
PHP Application Variables
07/02/2002 09:57 AMApplication Variables in PHP
Application Variables in PHP
07/01/2002 08:29 AMThis is the first article of several on developing an architecture
for Enterprise PHP, where we are running dedicated PHP servers tuned
to serve large number of web pages. This work originated in the need
to save the current working database connection as an Application
variable in a primary and fallback database server configuration. This
can be extended to saving other configuration information that rarely
changes... -- John Lim
"zeldman.jayne"
Variables and Paths
Variables and Paths
06/26/2002 07:05 PMIn this month's Q&A column, John Simpson answers questions about XSLT
variables and XML document paths.
Object-Variables-0.9
Object-Variables-0.9
07/30/2004 12:14 AMObject-Variables-0.5
Object-Variables-0.5
07/27/2004 12:28 AMObject-Variables-0.4
Object-Variables-0.4
07/25/2004 06:12 AMTunneling Variables
Tunneling Variables
04/09/2004 04:09 PMIn Bob DuCharme's latest Transforming XML column he explains the use
and virtues of XSLT 2.0's tunneled variables.
PHP Static Class Variables
PHP Static Class Variables
12/02/2002 01:17 PMStatic class variables are variables that are shared among all
instances
of a particular class. Although PHP supports static variables in
functions,
it has no support for static variables in classes. This functionality
can be pretty important in some situations, and I will now describe
a way to simulate it.
Hash variables in Perl
Hash variables in Perl
08/23/2004 02:48 AMCNET Aug 23 2004 7:15AM GMT
Perl's Special Variables
Perl's Special Variables
06/18/2004 07:05 PMDave Cross goes back to basics to show how using Perl's special
variables can tidy up file-handling code.
Using hash variables in Perl
Using hash variables in Perl
05/03/2004 09:19 AMCNET May 3 2004 1:48PM GMT
Variables used by the Status Filter
Variables used by the Status Filter
04/15/2004 02:26 PMThe Fuzzy Blog on Varaible Variables
The Fuzzy Blog on Varaible Variables
12/20/2002 08:49 AMTemplates with patTemplate, and Form
Variables
Templates with patTemplate, and Form
Variables
05/30/2002 08:10 AMA Guide to Basic Variables That Add To
Site Value
A Guide to Basic Variables That Add To
Site Value
03/17/2005 02:32 AMNice checklist of items to cover before buying or selling a site.
Using variables in Windows batch files
Using variables in Windows batch files
08/29/2004 02:23 PMTech-Recipes Aug 29 2004 6:35PM GMT
Learning Cocoa: Repurposing Variables
Learning Cocoa: Repurposing Variables
01/18/2004 02:48 PMSet Roby: "By now we know that every variable is really just a bunch
of bits, which we can look at a certain way and read as an integer, a
pointer, or whatever else we need to remember. Well, what else do we
want to remember?"
Keep track of stopped processes via
shell variables
Keep track of stopped processes via
shell variables
12/15/2003 11:45 AMEarlier hints discuss how to suspend and resume processes via kill --
very helpful to me, because I had been launching apps from Terminal
and using ^Z, fg and bg to manage them. A summary of previous hints:
kill -STOP and kil...
Copy variables from command line to GUI
environments
Copy variables from command line to GUI
environments
07/22/2004 09:59 AMIf you use the UNIX command line environment under OS X, you probably
know that the environment symbols you set up in your .bashrc file are
not reflected in the GUI environment. In the GUI environment, symbol
values are read...
Setting the %DSDIT%, %DSLOG%, and
%SYSVOL% Variables
Setting the %DSDIT%, %DSLOG%, and
%SYSVOL% Variables
09/10/2004 01:53 AMUnprivilegued settings for FreeBSD
kernel variables
Unprivilegued settings for FreeBSD
kernel variables
06/15/2004 01:41 PMRadko Keves (Jun 14 2004)
Re: Unprivilegued settings for FreeBSD
kernel variables
Re: Unprivilegued settings for FreeBSD
kernel variables
06/16/2004 06:16 PMDag-Erling Smørgrav (Jun 15 2004)
Working with Environment variables -
Add, Remove and Retrieve
Working with Environment variables -
Add, Remove and Retrieve
12/24/2004 12:49 PMTCB::Internal 1.03
TCB::Internal 1.03
05/19/2004 03:05 PMA CGI Web templating module
Top Tip: Internal USB hub?
Top Tip: Internal USB hub?
05/18/2004 04:29 AMIs it possible to add an internal USB hub? I have two front USB ports
and also an internal card reader. My motherboard has room for either
one of those but not both. Also, I have a firewire port on my case
front, but no place on my motherboard to plug it in.
TCB::Internal 1.02
TCB::Internal 1.02
05/15/2004 08:42 AMA CGI Web templating module
I’m Internal Too
I’m Internal Too
04/09/2004 04:05 PMFor those of you who work at Sun, there’s now an internal version of
ongoing at
http://webhome.sfbay/ongoing/
; check it out. Scoble says internal weblogs are intrinsically less
interesting than external ones; we’ll see.
Internal Policies
Internal Policies
02/17/2004 01:29 AMAgent - New release Available (v2.22)
Would That Be Internal or External,
Technically?
Would That Be Internal or External,
Technically?
07/30/2004 07:07 AM
I have nothing to say; I just love this
picture. Someday I will have one of these old-school hard drives on my
wall and I will be a happy man. (Thanks, O2!)
Lo
ok - New Hard Drive [Gizmodo]
Internal Instant Messenger
Internal Instant Messenger
07/29/2004 06:38 PMFirst release is nearly done
AskJeeves Names New Internal CEO
AskJeeves Names New Internal CEO
11/04/2003 02:28 PMThe best performing search stock of the last three years gets a new
CEO from inside the ranks.
TV Tuners For The PC: Internal Or
External
TV Tuners For The PC: Internal Or
External
06/19/2004 07:58 PMGrok Description matches for Internal Variables for Use in Your Scripts
GrokA matches for Internal Variables for Use in Your Scripts
Internal Variables for Use in Your Scripts