domingo, 8 de marzo de 2015

PHP Logical Operators


Logical Operators
Example Name Result
$a and $b And TRUE if both $a and $b are TRUE.
$a or $b Or TRUE if either $a or $b is TRUE.
$a xor $b Xor TRUE if either $a or $b is TRUE, but not both.
! $a Not TRUE if $a is not TRUE.
$a && $b And TRUE if both $a and $b are TRUE.
$a || $b Or TRUE if either $a or $b is TRUE.

miércoles, 4 de marzo de 2015

php regular expresion

<?

$line = "Vi is the greatest word processor ever created!";
// perform a case-Insensitive search for the word "Vi"
if (preg_match("/\bVi\b/i", $line, $match)) :
  print "Match found!";
endif;


echo "<br>";


if (preg_match("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}

?>

martes, 3 de marzo de 2015

Imprimiendo comilla doble en PHP

<?
echo  " asterisk -x \" sip show peers \"";

?>

Solo tenemos que poner un  \ delante de la comilla  ejemplo    <?php echo " \"hola"; ?>

imprime  "hola

Y esto   <?php   echo " \"hola\"";  ?>

"hola"
  

PHP Assignment by Reference

Assignment by Reference

Assignment by reference is also supported, using the "$var = &$othervar;" syntax. Assignment by reference means that both variables end up pointing at the same data, and nothing is copied anywhere.
Example #1 Assigning by reference
<?php
$a 
3;$b = &$a// $b is a reference to $a
print "$a\n"// prints 3print "$b\n"// prints 3
$a 4// change $a
print "$a\n"// prints 4print "$b\n"// prints 4 as well, since $b is a reference to $a, which has
              // been changed
?>
 
 
Esto es comoa acceso directo a  una variable 

domingo, 1 de marzo de 2015

Agregando valores automaticos a un arreglo he interactuando sobre ellos

<?php
$peers=array();

$peers[]=a;
$peers[]=b;
$peers[]=c;
$peers[]=d;


foreach ($peers as $extensions) {

echo $extensions."<br>";

$peers++;

}

?>

a
b
c
d

viernes, 27 de febrero de 2015

return devuelve el valor de una variable x llamada dentro de una funcion, y transforma la  funcion misma en una variable misma igual  al valor de la variable x ya mencionada con el return


ejemplo $a sera igual al valor de la suma de $var+$var1 y la funcion sum( $var,$var1) sera igual al valor de $a. Por ende podemos usar esta funcion como si fuese una variable


 <?
function sum($var,$var1){

$a=$var+$var1;

return $a;


}

 if(sum(10,10)==20){


 echo " function  value is 20";
}

else {

echo " function  value is  not  equal to 20";

}

?>

function  value is 20

martes, 24 de febrero de 2015

using-linux-awk-command-in-php

$output = exec('awk -v OFS=, \'/hello/i {$1=$1;print}\' test.txt > newtest.txt');
 
http://stackoverflow.com/questions/16419070/using-linux-awk-command-in-php