This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn = getenv("MYSQLCONNSTR_localdb"); // this will return the whole connectionstring in a single string | |
$conarr2 = explode(";",$conn); // Let's beautify it, by splitting it and decorating it in an array | |
$conarr = array(); | |
foreach($conarr2 as $key=>$value){ | |
$k = substr($value,0,strpos($value,'=')); | |
$conarr[$k] = substr($value,strpos($value,'=')+1); | |
} | |
print_r($conarr); // $conarr is an array of values of connection string | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Import PHPMailer classes into the global namespace | |
// These must be at the top of your script, not inside a function | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
//Load Composer's autoloader | |
require 'PHPMailer/autoload.php'; | |
$mail = new PHPMailer(true); // Passing `true` enables exceptions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sign Up Form</title> | |
</head> | |
<body> | |
<section> | |
<form class="c-form" action="" method="POST"> | |
<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a[0] = 1; // Numeric Array | |
$a[1] = 2; | |
$a[2] = 3; | |
$a[3] = 4; | |
$a[4] = 5; | |
$b['a']='a'; // Associative Array | |
$b['b']='b'; | |
$b['c']='c'; | |
$b['d']='d'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = fopen("test.txt","w+"); | |
// exclusive lock | |
if (flock($file,LOCK_EX)) | |
{ | |
fwrite($file,"Write something"); | |
// release lock | |
flock($file,LOCK_UN); | |
} | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo copy("source.txt","target.txt"); | |
//Another way | |
//Get all the content from the file | |
$fileContents = file_get_contents('1.txt'); | |
//Output to new file | |
$fh = fopen('output.txt', 'w+'); | |
file_put_contents($fh, $fileContents); | |
fclose($fh); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Check if the number is Even or Odd</title></head> | |
<body> | |
<form method="post"> | |
Enter the Number:<br> | |
<input type="number" name="number" id="number"> | |
<input type="submit" name="submit" value="Submit" /> | |
</form> | |
<?php | |
if($_POST['submit']){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Reverse of a given Number in PHP</title></head> | |
<body> | |
<form method="post"> | |
Enter the Number:<br> | |
<input type="number" name="number" id="number"> | |
<input type="submit" name="submit" value="Submit" /> | |
</form> | |
<?php | |
if($_POST['submit']){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Factorial Program using loop in PHP</title> | |
</head> | |
<body> | |
<form method="post"> | |
Enter the Number:<br> | |
<input type="number" name="number" id="number"> | |
<input type="submit" name="submit" value="Submit" /> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('Asia/Kolkata'); | |
$hour=date('h', time()); | |
$ampm=date('a', time()); | |
if($ampm=="am"){ | |
if($hour>=1 && $hour<=11){ | |
echo "Good Morning!!!"; | |
} | |
} |
NewerOlder