[ create a new paste ] login | about

martin@mustbebuilt.co.uk

Name: Martin Cooper
Email:
Site/Blog: http://www.mustbebuilt.co.uk
Location: United Kingdom
Default language: PHP
Favorite languages: PHP
About:

Saved pastes by martin@mustbebuilt.co.uk:

PHP, pasted on Oct 12:
1
2
3
4
5
<?php
function priceWithVAT($val){
	$priceVAT = $val * 1.2;
	$priceVAT = round($priceVAT, 2);
	return $priceVAT;
...
view (13 lines, 1 line of output)
PHP, pasted on Sep 8:
1
2
3
4
5
<?php
$age  = (int) 21;
$age = $age * 0.36;
echo $age;
?>
view (5 lines, 1 line of output)
PHP, pasted on Sep 8:
1
2
3
4
5
<?php
$age = 21;
$age = $age + "40 on please ";
echo $age;
?>
view (5 lines, 1 line of output)
PHP, pasted on Mar 13:
1
2
3
4
5
<?php
$first_name = "Martin";
echo "<h1>Welcome</h1>";
echo "<p>My name is {$first_name}</p>";
?>
view (5 lines, 1 line of output)
PHP, pasted on Oct 13:
1
2
3
4
5
<?php
$firstname = "Martin";
print('Some value');
echo "\n";
// won't show $firstname because of single quotes
...
view (15 lines, 6 lines of output)
PHP, pasted on Oct 13:
1
2
3
4
5
<?php
    $firstName = "Martin";
    $age = 21;
    echo $firstName;
    echo "\n";
...
view (27 lines, 7 lines of output)
PHP, pasted on Oct 13:
1
2
3
4
5
<?php
    $firstName = "Martin";
    echo $firstName;
    echo "First Name: " . $firstName;
    // or
...
view (9 lines, 1 line of output)
PHP, pasted on Dec 5:
1
2
3
4
5
<?php
$myarray = array('Guitar' => 'Johnny', 'Vocals'=> 'Stephen',
'Bass' => 'Andy', 'Drums' => 'Mike');
$myJson = json_encode($myarray);
echo $myJson;
...
view (6 lines, 1 line of output)
PHP, pasted on Dec 5:
1
2
3
4
5
<?php
$myJson = '{"Guitar":"Johnny","Vocals":"Stephen","Bass":"Andy","Drums":"Mike"}';
$myArray = json_decode($myJson, true);
print_r($myArray);
echo "{$myArray ['Vocals']}/n";
...
view (10 lines, 15 lines of output)
PHP, pasted on Oct 23:
1
2
3
4
5
<?php
$currentTime = time();
echo "$currentTime\n";
$mydate = mktime(1,30,50,12,13,1971);
echo "$mydate\n";
...
view (17 lines, 19 lines of output)
PHP, pasted on Oct 23:
1
2
3
4
<?php
$currentTime = time();
echo $currentTime;
?>
view (4 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
<?php
$housenames = array("Coniston", "River View", "Den's Den", "The Cottage");
print_r($housenames);
?>
view (4 lines, 7 lines of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
function priceWithVAT($val){
    $priceVAT = $val * 1.2;
    $priceVAT = round($priceVAT, 2);
    return $priceVAT;
...
view (8 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$myNum = 3.14159;
//
$myNumRound = round($myNum);
echo "Round $myNumRound\n";
...
view (19 lines, 5 lines of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$lies = "I love fruit";
$truth = str_replace("fruit", "chips", $lies);
echo $truth;
?>
view (5 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$fullname = "Martin Cooper";
$len = strlen($fullname);
$divider = strpos($fullname, " ");
$firstName = substr($fullname, 0, $divider);
...
view (9 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$fullname = "Martin Cooper";
$len = strlen($fullname);
echo $len;
//
...
view (7 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$fullname = "Martin Cooper";
$firstName = substr($fullname, 0, 6);
echo $firstName;
$surname = substr($fullname, 7, 6);
...
view (7 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
for($i=1;$i<10;$i++){
   echo "$i<br>";
} // outputs 1 to 9
?>
view (5 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
$count = 12;
do {
   print "$count<br>";
   $count--;
...
view (8 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
    $count = 1;
    while ($count < 10){
    print "$count<br>";
    $count++;
...
view (7 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
     if($weight > 10){
        $postage = 4.5;
    }else{
        $postage = 2;
...
view (8 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
4
5
<?php
     if($weight > 10){
        $postage = 4.5;
    }else{
        $postage = 2;
...
view (8 lines, 1 line of output)
PHP, pasted on Oct 22:
1
2
3
<?php
include('http://www.mustbebuilt.co.uk/');
?>
view (3 lines, 4 lines of output)
PHP, pasted on Oct 22:
1
2
3
<?php
include('http://www.mustbebuilt.co.uk/');
?>
view (3 lines, 4 lines of output)
PHP, pasted on Oct 21:
1
2
3
4
5
<?php
$type = 'box';
switch ($type){
	case 'box':
		$postage = 2.5;
...
view (17 lines, 1 line of output)
PHP, pasted on Oct 21:
1
2
3
4
5
<?php
$login = "bob";
if(!isset($login)){
    echo "Please Login";        
}else{
...
view (8 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
function checkNum($num) {
  if($num<10) {
    throw new Exception("Value must be more than 10");
  }
...
view (18 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
function checkNum($num) {
  if($num<10) {
    throw new Exception("Value must be more than 10");
  }
...
view (18 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
$feed = 1;
$action = (isset($feed)) ? 'Go' : 'Back';
echo $action; // outputs ‘Go’
?>
view (5 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
$someVar = 20;
$otherVal = ($someVar > 5) ? 'Bigger than 5' : 'Some Default';
echo $otherVal;
?>
view (5 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
$band  = array('Guitar' => 'Johnny', 'Vocals'=> 'Stephen', 'Bass' => 'Andy', 'Drums' => 'Mike');
foreach($band as $key => $myvalues){
    echo "On {$key} we have {$myvalues} <br>";
}
...
view (6 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
5
<?php
$myarray = array('Johnny', 'Stephen', 'Andy', 'Mike');
foreach($myarray as $value)
{
    echo "$value<br>";
...
view (7 lines, 1 line of output)
PHP, pasted on Sep 10:
1
2
3
4
<?php
$myCart = array(array(12532,'Widget',5.99,2));
echo $myCart[0][1];
?>
view (4 lines, 1 line of output)
PHP, pasted on Sep 2:
1
2
3
4
5
<?php
$myVal = $_GET['someVal']
if($myVal == true){
	echo "Hi';
}else{
...
view (7 lines, 2 lines of output)
PHP, pasted on Sep 2:
1
2
3
4
5
<?php
$myVal = $_GET['someVal']
if($myVal == true){
	echo "Hi";
}else{
...
view (7 lines, 2 lines of output)
PHP, pasted on May 1:
1
2
3
4
5
<?php
function getDirectory($full, $noDir=0){
    $pos1 = strripos($full, "/");
    $path = substr($full, $pos1);
    if($noDir == 0){
...
view (22 lines, 1 line of output)