crossz

Archive for the ‘symbol’ Category

@, in PHP

In symbol on April 30, 2009 at 2:19 am

To supresses error reporting.

Sometmes functions are called with “@’ in front of them -
E.g. $somevar = @mail($to,$subject,$msg);

#, in php regular expression

In php, symbol on March 12, 2009 at 7:42 pm
In PHP’s patterns, you always start with a delimiter (the first character in the pattern) and end with the same. Then follow it with any modifiers. These all work the same:

/[a-z]/i
#[a-z]#i
%[a-z]%i

#, in php regular expression

In php, symbol on March 12, 2009 at 7:42 pm
In PHP’s patterns, you always start with a delimiter (the first character in the pattern) and end with the same. Then follow it with any modifiers. These all work the same:

/[a-z]/i
#[a-z]#i
%[a-z]%i

&, in Joomla api, return reference to existing object

In joomla, symbol on March 6, 2009 at 2:06 am
Most of joomla api return reference, such as:
In this example, the current date and time is retrieved and output in the current default locale format.
=========================
$date =& JFactory::getDate();
echo ‘Current date and time is: ‘ . $date->toFormat() . “\n”;
If the current language is English then this will output something like
Current date and time is: 2008-11-22 18:14:08
=========================
This is because the returned object will update the existing one, while not creating new global one, except the object not created yet.
As explained here, in api.joomla.org:
=========================
getApplication (line 34)
Get a application object
Returns a reference to the global JApplication object, only creating it if it doesn’t already exist.
=========================

#_, in mysql query, in Joomla

In symbol on January 29, 2009 at 1:15 am
the database prefix can be entered in the form ‘#_’ (hash-underscore),
in which case it will automatically be replaced by the database prefix
used by Joomla.

from: http://docs.joomla.org/Sql_parameter_type

#_, in mysql query, in Joomla

In symbol on January 29, 2009 at 1:15 am
the database prefix can be entered in the form ‘#_’ (hash-underscore),
in which case it will automatically be replaced by the database prefix
used by Joomla.

from: http://docs.joomla.org/Sql_parameter_type

(), round brackets, in Mysql

In symbol on January 28, 2009 at 7:40 pm
(T1, …) RIGHT JOIN (T2,…) ON P(T1,…,T2,…) =
(T2, …) LEFT JOIN (T1,…) ON P(T1,…,T2,…)

http://dev.mysql.com/doc/refman/5.0/en/outer-join-simplification.html

===========

mysql> SELECT cds.artist, cds.title, genres.genre
-> FROM cds, genres
-> WHERE (cds.genreID = genres.genreID);

{}, curly braces, in Php, not mysql

In symbol on January 28, 2009 at 7:27 pm

Variable parsing

When a string is specified in double quotes or with heredoc,
variables are parsed within it.

There are two types of syntax: a
simple one and a
complex one.
The simple syntax is the most common and convenient. It provides a way to
embed a variable, an array value, or an object
property in a string with a minimum of effort.

The complex syntax was introduced in PHP 4, and can be recognised by the
curly braces surrounding the expression.


Simple syntax

If a dollar sign ($) is encountered, the parser will
greedily take as many tokens as possible to form a valid variable name.
Enclose the variable name in curly braces to explicitly specify the end of
the name.


<?php
$beer 
'Heineken';
echo 
"$beer's taste is great"// works; "'" is an invalid character for variable names
echo "He drank some $beers";   // won't work; 's' is a valid character for variable names but the variable is "$beer"
echo "He drank some ${beer}s"// works
echo "He drank some {$beer}s"// works
?>

Similarly, an array index or an object property
can be parsed. With array indices, the closing square bracket
(]) marks the end of the index. The same rules apply to
object properties as to simple variables.


<?php
// These examples are specific to using arrays inside of strings.
// When outside of a string, always quote array string keys and do not use
// {braces}.

// Show all errors
error_reporting(E_ALL);

$fruits = array('strawberry' => 'red''banana' => 'yellow');

// Works, but note that this works differently outside a string
echo "A banana is $fruits[banana].";

// Works
echo "A banana is {$fruits['banana']}.";

// Works, but PHP looks for a constant named banana first, as described below.
echo "A banana is {$fruits[banana]}.";

// Won't work, use braces.  This results in a parse error.
echo "A banana is $fruits['banana'].";

// Works
echo "A banana is " $fruits['banana'] . ".";

// Works
echo "This square is $square->width meters broad.";

// Won't work. For a solution, see the complex syntax.
echo "This square is $square->width00 centimeters broad.";
?>

For anything more complex, you should use the complex syntax.

{}, curly braces, in Php, not mysql

In symbol on January 28, 2009 at 7:27 pm

Variable parsing

When a string is specified in double quotes or with heredoc,
variables are parsed within it.

There are two types of syntax: a
simple one and a
complex one.
The simple syntax is the most common and convenient. It provides a way to
embed a variable, an array value, or an object
property in a string with a minimum of effort.

The complex syntax was introduced in PHP 4, and can be recognised by the
curly braces surrounding the expression.


Simple syntax

If a dollar sign ($) is encountered, the parser will
greedily take as many tokens as possible to form a valid variable name.
Enclose the variable name in curly braces to explicitly specify the end of
the name.


<?php
$beer 
'Heineken';
echo 
"$beer's taste is great"// works; "'" is an invalid character for variable names
echo "He drank some $beers";   // won't work; 's' is a valid character for variable names but the variable is "$beer"
echo "He drank some ${beer}s"// works
echo "He drank some {$beer}s"// works
?>

Similarly, an array index or an object property
can be parsed. With array indices, the closing square bracket
(]) marks the end of the index. The same rules apply to
object properties as to simple variables.


<?php
// These examples are specific to using arrays inside of strings.
// When outside of a string, always quote array string keys and do not use
// {braces}.

// Show all errors
error_reporting(E_ALL);

$fruits = array('strawberry' => 'red''banana' => 'yellow');

// Works, but note that this works differently outside a string
echo "A banana is $fruits[banana].";

// Works
echo "A banana is {$fruits['banana']}.";

// Works, but PHP looks for a constant named banana first, as described below.
echo "A banana is {$fruits[banana]}.";

// Won't work, use braces.  This results in a parse error.
echo "A banana is $fruits['banana'].";

// Works
echo "A banana is " $fruits['banana'] . ".";

// Works
echo "This square is $square->width meters broad.";

// Won't work. For a solution, see the complex syntax.
echo "This square is $square->width00 centimeters broad.";
?>

For anything more complex, you should use the complex syntax.

->, Objects and references, in Php

In symbol on January 28, 2009 at 6:55 pm
A PHP reference is an alias, which allows two different variables to write
to the same value. As of PHP5, an object variable doesn’t contain the object
itself as value anymore. It only contains a object identifier which allows
object accessors to find the actual object. When an object is sent by
argument, returned or assigned to another variable, the different variables
are not aliases: they hold a copy of the identifier, which points to the same
object.

Example #1 References and Objects


<?php
class {
    public 
$foo 1;
}  

$a = new A;
$b $a;     // $a and $b are copies of the same identifier
             // ($a) = ($b) = <id>
$b->foo 2;
echo 
$a->foo."\n";

$c = new A;
$d = &$c;    // $c and $d are references
             // ($c,$d) = <id>

$d->foo 2;
echo 
$c->foo."\n";

$e = new A;

function foo($obj) {
    
// ($obj) = ($e) = <id>
    
$obj->foo 2;
}

foo($e);
echo 
$e->foo."\n";

?>

The above example will output:

2<br />2<br />2<br />

->, Objects and references, in Php

In symbol on January 28, 2009 at 6:55 pm
A PHP reference is an alias, which allows two different variables to write
to the same value. As of PHP5, an object variable doesn’t contain the object
itself as value anymore. It only contains a object identifier which allows
object accessors to find the actual object. When an object is sent by
argument, returned or assigned to another variable, the different variables
are not aliases: they hold a copy of the identifier, which points to the same
object.

Example #1 References and Objects


<?php
class {
    public 
$foo 1;
}  

$a = new A;
$b $a;     // $a and $b are copies of the same identifier
             // ($a) = ($b) = <id>
$b->foo 2;
echo 
$a->foo."\n";

$c = new A;
$d = &$c;    // $c and $d are references
             // ($c,$d) = <id>

$d->foo 2;
echo 
$c->foo."\n";

$e = new A;

function foo($obj) {
    
// ($obj) = ($e) = <id>
    
$obj->foo 2;
}

foo($e);
echo 
$e->foo."\n";

?>

The above example will output:

2<br />2<br />2<br />

=>, in Php

In symbol on January 28, 2009 at 6:49 pm
paring arry keys and values.

Example #1 Ejemplo de array()


<?php
$frutas 
= array (
    
"frutas"  => array("a"=>"naranja""b"=>"plátano""c"=>"manzana"),
    
"números" => array(123456),
    
"hoyos"   => array("primero"=> "segundo""tercero")
);
?>

Example #2 Índice automático con array()


<?php
$array 
= array(1111,  1=> 1,  => 119=> 13);
print_r($array);
?>

El resultado del ejemplo seria:

Array<br />(<br />    [0] => 1<br />    [1] => 1<br />    [2] => 1<br />    [3] => 13<br />    [4] => 1<br />    [8] => 1<br />    [9] => 19<br />)<br />

=>, in Php

In symbol on January 28, 2009 at 6:49 pm
paring arry keys and values.

Example #1 Ejemplo de array()


<?php
$frutas 
= array (
    
"frutas"  => array("a"=>"naranja""b"=>"plátano""c"=>"manzana"),
    
"números" => array(123456),
    
"hoyos"   => array("primero"=> "segundo""tercero")
);
?>

Example #2 Índice automático con array()


<?php
$array 
= array(1111,  1=> 1,  => 119=> 13);
print_r($array);
?>

El resultado del ejemplo seria:

Array<br />(<br />    [0] => 1<br />    [1] => 1<br />    [2] => 1<br />    [3] => 13<br />    [4] => 1<br />    [8] => 1<br />    [9] => 19<br />)<br />

::, Scope Resolution Operator, in Php

In symbol on January 28, 2009 at 6:46 pm

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
simpler terms, the double colon, is a token that allows access to
static,
constant, and overridden
members or methods of a class.

When referencing these items from outside the class definition, use
the name of the class.

Example #1 :: from outside the class definition


<?php
class MyClass {
    const 
CONST_VALUE 'A constant value';
}

$classname 'MyClass';
echo 
$classname::CONST_VALUE// As of PHP 5.3.0

echo MyClass::CONST_VALUE;
?>

And, Static properties cannot be accessed through the object using the arrow
operator ->.

http://uk2.php.net/language.oop5.static

::, Scope Resolution Operator, in Php

In symbol on January 28, 2009 at 6:46 pm

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
simpler terms, the double colon, is a token that allows access to
static,
constant, and overridden
members or methods of a class.

When referencing these items from outside the class definition, use
the name of the class.

Example #1 :: from outside the class definition


<?php
class MyClass {
    const 
CONST_VALUE 'A constant value';
}

$classname 'MyClass';
echo 
$classname::CONST_VALUE// As of PHP 5.3.0

echo MyClass::CONST_VALUE;
?>

And, Static properties cannot be accessed through the object using the arrow
operator ->.

http://uk2.php.net/language.oop5.static

::, Scope Resolution Operator, in Php

In symbol on January 28, 2009 at 6:46 pm

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
simpler terms, the double colon, is a token that allows access to
static,
constant, and overridden
members or methods of a class.

When referencing these items from outside the class definition, use
the name of the class.

Example #1 :: from outside the class definition


<?php
class MyClass {
    const 
CONST_VALUE 'A constant value';
}

$classname 'MyClass';
echo 
$classname::CONST_VALUE// As of PHP 5.3.0

echo MyClass::CONST_VALUE;
?>

And, Static properties cannot be accessed through the object using the arrow
operator ->.

http://uk2.php.net/language.oop5.static

%, as Wildcard Usage, in Mysql

In symbol on January 28, 2009 at 6:29 pm

For example ‘2%’ would match the following: 20, 25, 2000000, 2avkldj3jklsaf, and 2!

$result = mysql_query(“SELECT * FROM example WHERE age LIKE ‘2%’ “)
or die(mysql_error());

&, ampersand, in php

In symbol on January 28, 2009 at 6:28 pm
in the following piece of code:

$a=10 ; //(1010b)
$b = 0; // (0000b)

if ($a & $b)

is different from

if ($a && $b)

The first one is true and the second if false.

When
we use only one & it means bit-by-bit and operation, so $a &
$b=10 (1010b), while when you use && it means and operator of
clauses and in this case $a && $b = 0, cause $b=0.

Beware of the signs. This FAQ is also valid for the or operator (‘|’).

&, ampersand, in php

In symbol on January 28, 2009 at 6:28 pm
in the following piece of code:

$a=10 ; //(1010b)
$b = 0; // (0000b)

if ($a & $b)

is different from

if ($a && $b)

The first one is true and the second if false.

When
we use only one & it means bit-by-bit and operation, so $a &
$b=10 (1010b), while when you use && it means and operator of
clauses and in this case $a && $b = 0, cause $b=0.

Beware of the signs. This FAQ is also valid for the or operator (‘|’).

&, ampersand, in php

In symbol on January 28, 2009 at 6:28 pm
in the following piece of code:

$a=10 ; //(1010b)
$b = 0; // (0000b)

if ($a & $b)

is different from

if ($a && $b)

The first one is true and the second if false.

When
we use only one & it means bit-by-bit and operation, so $a &
$b=10 (1010b), while when you use && it means and operator of
clauses and in this case $a && $b = 0, cause $b=0.

Beware of the signs. This FAQ is also valid for the or operator (‘|’).