stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors


Variable Handling and the PHP Novice







Variable Handling and the PHP Novice

Variable Handling and the PHP Novice 06/26/2002 01:01 PM

In the beginning, the file was void, and without text. The Programmer brought text to the file by saying "Let there be hello world" and there was hello world, and it was good. But soon hello world was not as good as it once was, and the Programmer said "let there be change!" And where there once was static content in the file, there was now variable content. Beholding the creation, the Programmer was happy, and all was well...




This is a GrokNews Entry: (what is grok?)





Similar Items

Variable Handling and the PHP Novice

Grok Headline matches for Variable Handling and the PHP Novice

Overclocking. Anything in it for the
Novice?


Overclocking. Anything in it for the
Novice?
07/15/2002 10:34 AM
Overclocking is easy if you have the right equipment to start with. It can cost nothing if your temps are ok. Its a quick, cheap and easy way to get more out of your PC.

make money online novice


make money online novice 04/10/2004 01:07 AM
WebDevInfo Apr 10 2004 5:28AM GMT

Internet chock full of tools that can
turn a novice investor into a pro


Internet chock full of tools that can
turn a novice investor into a pro
01/04/2005 04:21 AM
Globe and Mail Jan 4 2005 7:59AM GMT

Class to help novice learn to avoid
losing his shirt on eBay


Class to help novice learn to avoid
losing his shirt on eBay
06/20/2004 08:28 AM
Chicago Tribune Jun 20 2004 12:11PM GMT

Boca retiree teaches novice online
shoppers the ins and outs of using eBay


Boca retiree teaches novice online
shoppers the ins and outs of using eBay
04/10/2005 10:39 AM
Sun-sentinel.com - Sun Apr 10, 11:15 am GMT

ProWebmasterTools Offers Professional
Tools and Services to Webmasters Both
Expert and Novice


ProWebmasterTools Offers Professional
Tools and Services to Webmasters Both
Expert and Novice
03/19/2005 02:39 AM
Lovell Technology, LLC releases their newest Internet venture providing professional tools and services for Webmasters of any experience level. [PRWEB Mar 18, 2005]

Advanced Error Handling: Writing an
Error Handling Class


Advanced Error Handling: Writing an
Error Handling Class
11/10/2003 11:25 PM
If you're tired of the default error handler and want to have complete control over default error messages, you should write your own error handling class. Writing your own handler will enable you to change the way php handles your error messages, and allows you to create your own error types. With this class you will be able to send error messages to a log file, or send error reports via email.

Variable Variables in PHP


Variable Variables in PHP 12/19/2002 10:43 PM
Variable 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!

Install_Result Variable


Install_Result Variable 06/07/2004 06:57 PM

The Lowdown on Variable Annuities


The Lowdown on Variable Annuities 08/19/2004 09:27 AM
They're not all they're cracked up to be.

Variable Compliance Actuators


Variable Compliance Actuators 04/15/2004 06:21 PM
The CMU Robotics Institute has released a new technical paper title, "An Actuator with Mechanically Adjustable Series Compliance" (PDF format). It sounds complicated but basically what they're describing is the use of a spring with adjustable stiffness in the leg of a biped. The spring is adjusted to recover and reuse energy that would otherwise be lost when the robot is running, jumping, or performing other high-energy tasks. The paper includes plenty of background info, diagrams, and a photo of the complete leg actuator. The research is being done at the CMU Microdynamic Systems Lab.

Variable Naming Restrictions


Variable Naming Restrictions 05/28/2004 07:59 PM

Get Environment Variable Information


Get Environment Variable Information 08/30/2004 06:10 AM

Forum Stories: Variable for CDrom


Forum Stories: Variable for CDrom 08/22/2004 11:50 AM

SQL Server forum stories – Use db with
variable


SQL Server forum stories – Use db with
variable
07/22/2004 06:21 PM

Variable Intensity Brake Lights


Variable Intensity Brake Lights 08/10/2004 11:31 PM
Here's an idea. Why not design brake lights whose intensity varies depending up on how hard the driver is stomping on the pedal? It might help ease some of the overreaction I've seen on various highways and interstates in the last few years. According to a quick search, this isn't a new idea. But why it it only mentioned on the expensive 5 series BMW cars?...

phpBB datenbank mod has XSS/SQL
Injection in the id variable


phpBB datenbank mod has XSS/SQL
Injection in the id variable
04/16/2005 02:52 PM
Posted by tom cruise, Apr 16 2005

LDAP plug-in allows variable
substitution


LDAP plug-in allows variable
substitution
06/08/2004 12:04 PM
I was gob-smacked to discover that the current version (1.6.2) of the LDAP plug-in for Directory Access supports variable substitution in its LDAP mappings! This wasn't the case with the plug-in not so long ago, so I don't k...

Variable fees to fund bursaries


Variable fees to fund bursaries 01/19/2004 12:52 PM
Exeter University backs the government's tuition fees plan - saying it will mean £4m in bursaries for poorer students.

Forum Stories: Truncate a variable


Forum Stories: Truncate a variable 07/05/2004 04:11 PM

Using the OS Environment Variable in SMS
Installer to Test for NT Workstation


Using the OS Environment Variable in SMS
Installer to Test for NT Workstation
07/03/2004 06:20 PM

Getting the START Menu Directory into a
SMS Installer Variable


Getting the START Menu Directory into a
SMS Installer Variable
07/01/2004 10:18 PM

Forum Stories: User Desktop Variable


Forum Stories: User Desktop Variable 07/27/2004 07:32 AM

SMS Installer Walkthrough: Compiler
Variable If Script Action


SMS Installer Walkthrough: Compiler
Variable If Script Action
12/31/2004 10:30 AM

SMS Installer Walkthrough: Get
Environment Variable Script Action


SMS Installer Walkthrough: Get
Environment Variable Script Action
12/26/2004 07:19 AM

QuarkXPress module offers variable data
capabilities


QuarkXPress module offers variable data
capabilities
05/07/2004 12:09 PM
Quark today announced the release of QuarkXClusive, a new XTensions module for QuarkXPress 6 that offers powerful variable data publishing capabilities...

SMS Installer Walkthrough: Compiler
Variable Else Script Action


SMS Installer Walkthrough: Compiler
Variable Else Script Action
08/12/2004 11:51 PM

Cross-Browser Variable Opacity with PNG:
A Real Solution


Cross-Browser Variable Opacity with PNG:
A Real Solution
01/07/2004 07:11 PM
Think you're stuck with wimpy GIFs and their rigid binary transparency? Well, think again, Sunshine. Michael Lovitt shows how to overcome flaky browser support for PNG so you can take advantage of this graphic format's lossless compression, alpha transparency, and variable opacity.

Working Draft: SPARQL Variable Binding
Results XML Format


Working Draft: SPARQL Variable Binding
Results XML Format
12/22/2004 01:11 AM
2004-12-21: The RDF Data Access Working Group has released the First Public Working Draft of the SPARQL Variable Binding Results XML Format. The SPARQL query language (pronounced "sparkle") offers developers and end users a way to write and to consume search results across a wide range of information such as personal data, social networks and metadata about digital artifacts like music and images. SPARQL also provides a means of integration over disparate sources. Visit the Semantic Web home page. (News archive)

SA04-002 - Apache config file env
variable buffer overflow


SA04-002 - Apache config file env
variable buffer overflow
09/15/2004 01:22 PM
jonas.thambert_at_pts.se (Sep 15 2004)

Windows Installer Secrets and Traps –
Path Environment Variable


Windows Installer Secrets and Traps –
Path Environment Variable
02/17/2004 06:32 PM

NSFOCUS SA2003-08: HP-UX libc NLSPATH
Environment Variable Privilege Elevation
Vulnerability


NSFOCUS SA2003-08: HP-UX libc NLSPATH
Environment Variable Privilege Elevation
Vulnerability
11/13/2003 12:26 PM
NSFOCUS Security Team (Nov 13 2003)

Subscribe Me Pro/Enterprise - Remote
Code Execution via Backticked Perl
Variable Injection.


Subscribe Me Pro/Enterprise - Remote
Code Execution via Backticked Perl
Variable Injection.
12/19/2003 05:09 PM
Paul Craig - Pimp Industries (Dec 18 2003)

MDKSA-2004:049 - Updated libneon
packages fix heap variable overflow
issues


MDKSA-2004:049 - Updated libneon
packages fix heap variable overflow
issues
05/19/2004 02:58 PM
Mandrake Linux Security Team (May 19 2004)

New Technology Can Improve Direct Mail
Response Rate Up to 500 Times -Marketers
Using Variable Data Printing to Connect
with Consumers


New Technology Can Improve Direct Mail
Response Rate Up to 500 Times -Marketers
Using Variable Data Printing to Connect
with Consumers
06/24/2005 09:03 PM
New variable data printing technology improves Direct Mail Response Rates by connecting directly with consumers. [PRWEB Jun 23, 2005]

The W3C RDF Data Access Working Group
has published the first public working
draft of SPARQL Variable Binding


The W3C RDF Data Access Working Group
has published the first public working
draft of SPARQL Variable Binding
01/02/2005 11:31 AM
xmlhack Jan 2 2005 1:45PM GMT

Handling events in C#


Handling events in C# 10/01/2002 11:42 PM
CNET Oct 1 2002 10:01PM ET

RFC: virus handling


RFC: virus handling 01/28/2004 03:36 PM
Thomas Zehetbauer (Jan 28 2004)

Simple IO Handling with IO::All


Simple IO Handling with IO::All 04/09/2004 04:00 PM
Perl module author extraordinaire Brian Ingerson demonstrates his latest creation. IO::All ties together almost all of Perl's IO handling libraries in one neat, cohesive package.
Grok Description matches for Variable Handling and the PHP Novice
GrokA matches for Variable Handling and the PHP Novice

Gimme some sugar, I am your neighbor!


Gimme some sugar, I am your neighbor! 01/23/2004 04:16 PM
Andre 3000, Meet Schroeder. Well, it's not flash, but it's good for a Friday... Charlie Brown meets OutKast.

A Perl script to find duplicate iTunes
tracks


A Perl script to find duplicate iTunes
tracks
09/17/2004 10:31 AM
For some reason, I end up with a ton of "duplicate" tracks in my iTunes library and playlists. By this I mean that more than one track in iTunes maps to a single file on my hard drive. I may get into this problem because I s...

A script to remove duplicate messages
from Mail.app


A script to remove duplicate messages
from Mail.app
12/27/2003 05:25 PM
Some bug in Mail.app of Panther leads to multiple downloads of the same messages (at least in my configuration). It's a pain to manually remove all these massages again and again. Luckily, I found Andreas Amann's Mail Scripts...

Zizasoft Releases zsDuplicateHunter a
New Utility to Find and Remove Duplicate
Files From Computers and Updates
zsCompare to Version 2.10


Zizasoft Releases zsDuplicateHunter a
New Utility to Find and Remove Duplicate
Files From Computers and Updates
zsCompare to Version 2.10
08/19/2004 02:10 AM
Zizasoft has released zsDuplicateHunter, a new utility which allows you to find and remove duplicate files from your computer. zsDuplicateHunter runs on all modern versions of Windows and Mac OS X 10.3 or later. The functionality of zsDuplicateHunter is also included in zsCompare version 2.10. [PRWEB Aug 19, 2004]

Sugar Free Jelly Worms [Flickr]


Sugar Free Jelly Worms [Flickr] 02/01/2005 09:34 PM

Delete artwork from multiple songs in
iTunes


Delete artwork from multiple songs in
iTunes
06/29/2004 08:58 AM
The old way of removing cover art in iTunes was to scale down to a lower MP3 tag, or individually edit Get Info boxes. Today I found out through trial and error that when selecting multiple songs, opening Get Info, and unchec...

Duplicate and Empty Elements


Duplicate and Empty Elements 10/02/2002 06:06 PM
In his monthly Transforming XML column, Bob DuCharme explains how to detect, delete, and create duplicate and empty elements in source and result trees.

Duplicate and empty elements (XML.com)


Duplicate and empty elements (XML.com) 10/08/2002 07:08 AM

SMS Query to Determine Duplicate IDs


SMS Query to Determine Duplicate IDs 07/14/2004 06:31 PM

Duplicate Computer Name Collection


Duplicate Computer Name Collection 08/19/2004 10:46 PM

Managing Tracks: Delete Never Played
Songs from iTunes


Managing Tracks: Delete Never Played
Songs from iTunes
12/17/2004 06:30 PM
This script will survey the selected Playlist for tracks with a play count of 0 and remove them completely from iTunes, then Trash their files. Use with extreme caution!

Find Duplicate Music Files 0.0.9g


Find Duplicate Music Files 0.0.9g 08/08/2004 02:08 AM
Finds music files that are likely to contain the same music.

Find Duplicate Music Files 0.0.9f


Find Duplicate Music Files 0.0.9f 07/26/2004 04:08 PM
Finds music files that are likely to contain the same music.

10.3: Removing duplicate fonts using
FontBook


10.3: Removing duplicate fonts using
FontBook
10/29/2003 12:32 PM
If you open FontBook and see dots at the end of the font name, it means you have duplicate copies of that font installed in your system. To get rid of these, select the version of the font you want to use, and then click Edit...

Find Duplicate Music Files 0.0.9j


Find Duplicate Music Files 0.0.9j 08/15/2004 02:02 AM
Finds music files that are likely to contain the same music.

Duplicate posts in .Text bl0gs


Duplicate posts in .Text bl0gs 01/05/2004 11:31 PM
For anyone that noticed a lot of duplicate posts recently in .Text weblogs, this is not a SharpReader bug, but rather a result of some changes in the rss generated by .Text in a recent version. These changes are: <guid>, which went from http://{site}/{blogname}/posts/{post-number}.aspx to http://{site}/{blogname}/archive/{year}/{month}/{day}/{post-number}.as px <link>, which was changed in the same way. <description>, which now adds an invisible... (245 words)

Duplicate GUID Detection and Removal


Duplicate GUID Detection and Removal 09/09/2004 10:47 AM

Find Duplicate Music Files 0.0.4


Find Duplicate Music Files 0.0.4 06/01/2004 05:13 PM
Finds music files that are likely to contain the same music.

With copiers, can HP print unit
duplicate its success?


With copiers, can HP print unit
duplicate its success?
11/11/2003 05:45 PM
Hewlett-Packard will use Comdex to discuss new moves to ensure that its printer division can continue to thrive. A push into copiers has been a big part of the strategy.

Notes and Tips: Duplicate Disk Images


Notes and Tips: Duplicate Disk Images 08/31/2004 03:13 PM
Mounting multiple copies of a disk image in Mac OS X creates problems.

Stop repeating yourself: Duplicate file
finders


Stop repeating yourself: Duplicate file
finders
04/25/2004 08:41 PM
ZDNet Apr 26 2004 0:36AM GMT

"DeDRMs, remove iTunes DRM under
Windows "


"DeDRMs, remove iTunes DRM under
Windows "
04/27/2004 08:57 AM

Easy Duplicate GUID Detection Via
Command Line


Easy Duplicate GUID Detection Via
Command Line
05/21/2004 12:54 PM

Variable Handling and the PHP Novice

The following phrases have been identified by the grok system as matching this entry: "gimme some sugar" "i am your neighbor" mp3 "flickr api" "php class" "php treat: a variable variable tutorial." "delete itunes duplicate" "remove duplicate in itunes" if (substr($a, -3, 3) == "htm" || "html") flickr/api.php example

















Also check out:


Grok

Ipod Porn on the
Rise

Brief Abstract of
Wikipedia's
Mesothelioma Cancer
page

Get first aid
instructions in your
cell phone

IE is crap
JSPWiki gains
podcasting support

Making PDFs with
PHP, PDQ

Using Java objects
in PHP scripts Part
2

Managing Images With
a Web Database
Application

Five Little PHP
Tricks to
Programming Bliss

The Power Of Three:
XML, XSLT and PHP --
Part III

PHP Class
'CurrencyFormatter'
released

PHP Handy off the
Web, Too

International PHP
Conference 2002 call
for papers

Peeking Under the
Lid of Open Source
.NET CLI
Implementation

Vote to create
comp.lang.php
newsgroup

Open-source servers
today: PHP prowls
the edge

Nola and Noguska,
where art thou?

The Big Secret:
Palladium

HTML_TreeMenu
DirectoryBrowser
bin2array
inifile
CurrencyFormatter
Can XML Be The Same
After W3C XML
Schema?

PDF Presentations
Using AxPoint

RELAX NG's Compact
Syntax

document.body,
doctype switching,
and more

Remembering
Non-Registered
Visitors

Book Review: Usable
Web Menus

Information Design:
What is it? Who
needs it?

Bill Moggridge of
IDEO presents
User-Centred Design
at One Remove

Three Down and Yet
More to Come

New Book: Definitive
XML Application
Development

Project and proposal
for integrating
validation with
processing pipelines

Can a foreign
assignment help your
career?

Making multiple
session IDs work in
ASP

Can certification
aid your job search?

Programming within
your comfort zone

Better multiplatform
build system

The May Builder.com
top 10

Is SQL a standard
anymore?

ASP.NET security
holes

Get started with
EJBs

Cool Effects
Tutorials

HTML Utopia --
Designing Without
Tables: Part 2

A hitchhiker's guide
to alternate .NET
languages

First Look:
Dreamweaver MXA
Dream for Developers

Beyond browsing:
Tools for the
advanced Web surfer

Get The Look -
Design Templates

Ask Jeeves Uses
Acquisitions To Its
Advantage

Older Windows
Versions Left Out Of
Code Cleanup

On2 Throws More
Open-Source at
MPEG-4

IBM Unloads SDK for
Web Services

XML-Signature XPath
Filter Last Call
Published

Speech Recognition
Grammar
Specification
Advances to
Candidate
Recommendation

what is grok?