Recent Notes
Displaying keyword search results 1 - 6
Created by jinx on April 28, 2011 21:09:08
Last update: April 28, 2011 21:09:08
PHP global variables are defined outside of functions and classes. They are visible both in the current file and in any included/required files. Also, any global variables defined in required/included files are visible in the current file. But they are not visible in any functions or classes, unless specifically declared global .
Test:
Create file test.php :
<?php
ini_set('display_errors', 'stderr');
i...
Create file test.inc :
<?php
echo '[', __FILE__, '] $a . $b = ', $...
Run the PHP script in command line:
php test.php 2>C:\tmp\stderr.out
The result is:
[C:\work\test.inc] $a . $b = ab
[C:\work\test.p...
stderr messages:
PHP Notice: Undefined variable: b in C:\work\scra...
Created by Dr. Xi on December 05, 2009 20:12:16
Last update: December 05, 2009 20:46:45
It's quite easy for Perl to open a pipe and read from it:
$file = "nospace.txt";
open(IN, "cat $file |") ...
But the code breaks when the file name contains a space:
# This does not work!
$file = "yes space.txt";
...
On Windows, these don't work either:
# This does not work!
$file = "yes space.txt";
...
You need to use a technique called Safe Pipe Opens :
$file = "yes space.txt";
$prog = "cat";
...
Created by Dr. Xi on December 04, 2009 04:33:05
Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...
Created by Dr. Xi on September 29, 2008 23:05:12
Last update: September 29, 2008 23:06:16
These variables are set or used by the Unix shell to modify its behavior. Variable Description ENV=file Name of script that gets executed at startup; Usually, ENV=$HOME/.kshrc FCEDIT=file Editor used by fc (fix command) command. If $FCEDIT is not defined, use $EDITOR, otherwise use the default (vi or ed). FPATH=dirs Directories to search for function definitions; undefined functions are set via typeset -fu . FPATH is searched when these functions are first referenced. HISTFILE=file File in which to store command history. Default is $HOME/.sh_history for Korn shell, $HOME/.bash_history for Bash. If not set, history is lost after logout. HISTSIZE=n Max number of commands to keep in history. HOME=dir Home directory; set by login from passwd file. IFS='chars' Internal field separators. Default is space, tab, and...
Created by Dr. Xi on September 23, 2008 20:43:58
Last update: September 23, 2008 20:43:58
Variable Description
$0 The name of the ruby script file
$* The command line arguments
$$ Ruby interpreter's process ID
$? Exit status of last executed child process
$_ String last read by gets
$. Line number last read by interpreter
$! Last error message
$@ Location of error
$& String last matched by regexp
$~ The last regexp match, as an array of subexpressions
$n the nth subexpression in the last match (same as $~ )
$= Sase-insensitivity flag
$/ Input record separator
$\ Output record separator
Created by Dr. Xi on April 26, 2007 03:17:14
Last update: May 05, 2007 19:50:26
To loop through an envionment variable:
@echo off
set a=1 2 3
for %%i in (%a%) d...
To loop through the command line arguments:
@echo off
for %%i in (%*) do echo %%i