Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

hello

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
?>
</body>
</html>

TMKC

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Simpsons Array

php

<html>
<head>
<title>Simpson Array</title>
</head>
<body>
<?php
    //create an array
    $simpson[1] = "Homer";
    $simpson[2] = "Marje";
    $simpson[3] = "Bart";
    $simpson[4] = "Lisa";
    $simpson[5] = "Santa's Little Helper";

?>

</body>
</html>


test

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Execute PHP Online

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
// https://www.codediesel.com/php/generating-upc-check-digit/
function generateUpcCheckdigit($upc_code)
{
    $odd_total = 0;
    $even_total = 0;
    for ($i = 1; $i <= strlen($upc_code); $i++) {
        //echo "Checking i=$i ({$upc_code[$i - 1]})...\n";
        if ($i % 2 == 0) {
            //echo "even\n";
            /* Sum even digits */
            $even_total += $upc_code[$i - 1];
        } else {
            //echo "odd\n";
            /* Sum odd digits */
            $odd_total += $upc_code[$i - 1];
        }
    }
    $sum = (3 * $even_total) + $odd_total;
    //echo "Sum: $sum\n";
    /* Get the remainder MOD 10*/
    $check_digit = $sum % 10;
    /* If the result is not zero, subtract the result from ten. */
    return ($check_digit > 0) ? 10 - $check_digit : $check_digit;
}
$coupons = [
    [
        'signature' => 9210,
        'description' => '10% off',
    ],
    [
        'signature' => 9329,
        'description' => '$10 off $50',
    ],
    [
        'signature' => 9342,
        'description' => '$15 off $75',
    ],
    [
        'signature' => 9335,
        'description' => '$20 off $100',
    ],
    [
        'signature' => 9384,
        'description' => '$40 off $200',
    ],
    [
        'signature' => 9390,
        'description' => '$60 off $400',
    ],
];
foreach ($coupons as $coupon) {
    echo "{$coupon['description']}:" . PHP_EOL;
    for ($i = 0; $i < 10; $i++) {
        $upc_code = '47000' . rand(0, 4) . rand(1000, 9999) . $coupon['signature'];
        echo $upc_code . generateUpcCheckdigit($upc_code) . PHP_EOL;
    }
    echo PHP_EOL;
}
?>
</body>
</html>

Execute PHP Online

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
// https://www.codediesel.com/php/generating-upc-check-digit/
function generateUpcCheckdigit($upc_code)
{
    $odd_total = 0;
    $even_total = 0;
    for ($i = 1; $i <= strlen($upc_code); $i++) {
        //echo "Checking i=$i ({$upc_code[$i - 1]})...\n";
        if ($i % 2 == 0) {
            //echo "even\n";
            /* Sum even digits */
            $even_total += $upc_code[$i - 1];
        } else {
            //echo "odd\n";
            /* Sum odd digits */
            $odd_total += $upc_code[$i - 1];
        }
    }
    $sum = (3 * $even_total) + $odd_total;
    //echo "Sum: $sum\n";
    /* Get the remainder MOD 10*/
    $check_digit = $sum % 10;
    /* If the result is not zero, subtract the result from ten. */
    return ($check_digit > 0) ? 10 - $check_digit : $check_digit;
}
$coupons = [
    [
        'signature' => 9210,
        'description' => '10% off',
    ],
    [
        'signature' => 9329,
        'description' => '$10 off $50',
    ],
    [
        'signature' => 9342,
        'description' => '$15 off $75',
    ],
    [
        'signature' => 9335,
        'description' => '$20 off $100',
    ],
    [
        'signature' => 9384,
        'description' => '$40 off $200',
    ],
    [
        'signature' => 9390,
        'description' => '$60 off $400',
    ],
];
foreach ($coupons as $coupon) {
    echo "{$coupon['description']}:" . PHP_EOL;
    for ($i = 0; $i < 10; $i++) {
        $upc_code = '47000' . rand(0, 4) . rand(1000, 9999) . $coupon['signature'];
        echo $upc_code . generateUpcCheckdigit($upc_code) . PHP_EOL;
    }
    echo PHP_EOL;
}
?>
</body>
</html>

<html> <head> <title> Index </title> </head> <body> <?php echo "hello, world!!"; ?> </body> </html>

php

<html>

<head>
<title> Index </title>
</head>

<body>

<?php 
	echo "hello, world!!";
?>


</body>

</html>

PHP Coding

php

<body>
<?php	
$answer; // this is a global variable (declared outside function)
function calc()
	{
   		$miles = $_POST['mileage'];
		$fuel = $_POST['fuel']; 
		global $answer;
		$answer = $miles / $fuel;
		echo $answer;
	}
?>
<form name="form1" method="post" action="fuel_calc.php">
<p>Enter mileage:<input name="mileage" type="text" /><br/><br/>
   Enter fuel used (gallons): <input name="fuel" type="text" />
</p>
<p><input type="submit" name="submit" value="Submit" /><br/></p>
<p><input type="text" name="answer" value="<?php if (isset($_POST["submit"])){calc();}?>" />
</p>
</form>
<?php if (isset($_POST["submit"])){echo "Your fuel consumption is "."$answer"." miles per gallon";} ?>


</body>

amma

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Umer

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello</h1>\n";
?>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.