Last active
November 23, 2021 13:38
-
-
Save erikfritas/80f1200a7c870091620e8cc3bf1a0878 to your computer and use it in GitHub Desktop.
This file contains 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 is a very powerful language and I really recommend you get to know it. | |
* | |
* By @erikfritas from LUMAY | |
*/ | |
// Variables in PHP: | |
$string = 'value'; | |
$char = 'a'; # actually is a string | |
$int = 12345678910111213141516171819202122; | |
$float = 12.22; | |
$boolean = true; # or false | |
$array = [ 'hello' ]; | |
$obj = [ 'name' => 'erikfritas' ]; | |
$array_and_obj = [ 'hello', 'name' => 'erikfritas' ]; | |
# loops | |
for ($i=0; $i<count($array); $i++){} | |
foreach ($array as $i){} | |
while (true){} | |
switch ($string){ | |
case 'value': | |
echo 'string is equals "value"'; | |
break; | |
default: | |
echo "string isn't equals 'value'"; | |
break; | |
} | |
# Array Functs | |
$request = [ 'hi' => 'hello sir!', "what's your name?" ]; | |
$response = [ 'hi' => 'hello!', "I'm fine thanks!" ]; | |
$request_and_response = array_merge($request, $response); | |
$req_keys = array_keys($request); | |
$req_values = array_values($request); | |
array_push($request, "What? Did I ask what your name is?"); | |
// etc... | |
# MySQL | |
$pdo = new PDO('mysql:host=NameOfTheHost;dbname=NameOfDataBase;charset=utf8;', 'username', 'password'); | |
$query = $pdo->prepare('INSERT INTO `users` VALUES (null,?,?)'); | |
$query->execute(['value1', 'value2']); | |
// etc... | |
/** | |
* Hey liked it, I hope I helped! | |
* Find out more by visiting the language's official website: https://www.php.net/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment