Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
phpfiddle / fiddle_081491.php
Created September 9, 2017 17:33
[ Posted by Alfertson Cedano ] PHP tratamiento de nulos, vacíos, en blanco
<?php
$arrVacio=array();
$varDeclarada;
$arrValores=array(
'vacio ("")'=>'',
'en blanco (" ")'=>' ',
'NULL'=>NULL,
'TRUE'=>TRUE,
'FALSE'=>FALSE,
'0 (como cadena)'=>'0',
@phpfiddle
phpfiddle / fiddle_065977.php
Created September 9, 2017 01:44
[ Posted by Jose ] Pass values to parameters in a PHP function
<?php
function greeting($name, $age) {
return "<h1>Hello " . $name . " you are " . $age . " years old today. Happy Birthday!!</h1>";
}
echo greeting('Billy', '146');
?>
@phpfiddle
phpfiddle / fiddle_012292.php
Created September 1, 2017 19:06
[ Posted by Diegovieira ] xxxxxxxxxxxxxxxxxx
<?php
$n = '2.2737367544323E-13';
$n = preg_replace('/[^0-9.]/', '', $n);
echo number_format($n, 2, '.', '');
?>
@phpfiddle
phpfiddle / fiddle_015781.php
Created August 21, 2017 06:14
[ Posted by Jeganrajaiya ] string-to-array
<?php
$str = "parital Under production";
$result = explode(' ', $str, 2);
print_r($result);
?>
@phpfiddle
phpfiddle / fiddle_059392.php
Created August 14, 2017 00:48
[ Posted by Harmeet ] currency converter try
<html>
<form>
<input type="text" name="currency" method="post">
<select name='cur1'>
<option value="can">Candian Dollor(AUD)</option>
<option value="USD" selected>US Dollar(USD)</option>
<option value="inr" selected>indian rupee</option>
</select>
@phpfiddle
phpfiddle / fiddle_020822.php
Created August 9, 2017 19:54
[ Posted by Ezzcardoso ] teste de teste .............................
<?php
gfhgh
?>
@phpfiddle
phpfiddle / fiddle_084708.php
Created August 9, 2017 13:39
[ Posted by Suman ] Open Assignment
<!DOCTYPE html>
<html>
<body>
<div> Open Work Example </div>
<?php
$workid = "S-95";
/* In a production scenario, this id would be retrieved dynamically maybe from a rest service which takes in a few input search
parameters and returns the id, like get me the id of the loan application of ApplicantName = xxx
*/
@phpfiddle
phpfiddle / fiddle_012598.php
Created August 9, 2017 06:18
[ Posted by Alfertson Cedano ] PDO query sin consultas preparadas
<?php
/**
*
* Consulta con PDO mediante query
*
* Notas:
* - Los require indicados solo sirven para este ejemplo
* - La consulta SQL y el resultado son sólo para mostrar un ejemplo ,
* cada uno debe adaptarla a sus necesidades
@phpfiddle
phpfiddle / fiddle_042398.php
Created August 7, 2017 10:21
[ Posted by Suman ] This is a dynamic page which serves the mashup for action openWorkItem .
<!DOCTYPE html>
<html>
<body>
<div> Open Work Example </div>
<?php
$workid = "S-95";
/* In a production scenario, this id would be retrieved dynamically maybe from a rest service which takes in a few input search
parameters and returns the id, like get me the id of the loan application of ApplicantName = xxx
*/
@phpfiddle
phpfiddle / fiddle_037941.php
Created August 1, 2017 01:37
[ Posted by Schand ] isDecimal vs is_float
<?php
function isDecimal($value) {
return ((float) $value !== floor($value));
}
$test_vars = array("10","1.01", "1.0101");
foreach ($test_vars as $var) {
echo $var . "is_float: " . is_float($var) . " | isDecimal:" . isDecimal($var) . "<br>";
}