//this file is about arrays //empty array $ar = array(); //add value "4" to first possible index $ar[] = 4; foreach ($ar as $b); { echo $b."
"; } //add value "5" to second index $ar[2] = 5; foreach ($ar as $b); { echo $b; }
symfony expert
Montag, 2. Juni 2014
PHP Basics: Storing Creating and storing Arrays
Arrays are very powerful. You can use them to store a set of data, compare them and update them incrementally.
Here is a short example how adding is one
Sonntag, 1. Juni 2014
PHP Basics: How can I convert from "int" to "bool", "float", "string", "array", "object"
converting variables using "int", "bool", "float", "string", "array", "object".
There are several ways to cast a variable into a different variable type. This is useful in order to control what type a
variable currently is. there are specific cast commands, yet you can also assign the operators in order to make sure the
variable behaves as expected
Be aware that even tough integer variables can hold significant data of up to 2147483647 on a 32-Bit system, therefor they can run into overload.
$k = 4; //this will initialize the variable and set it up to be an integer $l = (float) $k; // this converts the variable to a float var_dump($l);The Output is "float(4)", since the variable was converted from integer to float
Be aware that even tough integer variables can hold significant data of up to 2147483647 on a 32-Bit system, therefor they can run into overload.
PHP Basics: Converting variables integer, float, string
//type conversion: php performs automatic variable casting. make sure you get what happens behind the scenes. $variable_g = "1"; // the result is an integer $variable_h = "1.0"; // the result is a float $combined_variable = $variable_g + $variable_h; // this combines the two into a new version var_dump($combined_variable);the output is: "float(2)", the variable was cast into a float
// then connecting two variables, in this case an integer with a float using the "." connector the result is a string $variable_i = "1"; // the result is an integer $variable_j = "1.0"; // the result is a float $combined_variable = $variable_i.$variable_j; // this combines the two into a new version var_dump($combined_variable);the output is a "string(4) "11.0"
PHP Basics: How to use Git and Github quickly?
Learing to use Github or Bitbucket is essential.
It helps to get store own projects, fetch code that you can use to learn or contribute to open source projects.
What is the best way to learn Github? Learn it here within less than one hour.
What is the best way to learn Github? Learn it here within less than one hour.
- Register an Account on Github.com
- Watch these 2 Videos on 2x speed
- Within an hour you're done with the basics
- Very helpful: If you've got an Amazon Kindle: Grab the free Mobi Book avilable at http://git-scm.com/book
PHP Basics: How can I print the n-th Character of a PHP String?
// grabbing single elements out of a variable // define the variable, in this case "NeilArmstrong" $variable_f = "NeilArmstrong"; // write the variable using the echo command and counting to a specific character, in this case number 0 and 5 echo $variable_f[0]; echo $variable_f[5];Wrapping this into a php file and running it will give you the following output "Nr" since the first Character of the string is "N" and the 5th is "r"
Sonntag, 11. Mai 2014
20 Putty Commands
When deploying Code, you want to use putty for easy and fast filetransfer.
General:
1. To show your current location pwd
2. To find out which user you are: whoami
3. To display current server date and time: date
4. To open the manual pages for commands: man
5. quit or exit an application: q
Directories:
6. To list folders or directories use: “ls” or “dir”
7. To make a directory: mkdir
8. To change directories: “cd /path/to/your/directory”
9. To delete a directory: “rm -rf directoryname”
10. To change up one directory: “cd ..” (two directories: “cd ../..”)
Files:
11. To Copy a file with: cp
12. To move a file, also used to rename files: mv
13. To remove a file: rm
14. To upload a file: “wget http://www.yourhost.com/yourfile.tar.gz”
15. To delete a file: “rm filename”
16. To unzip a zip file: “unzip filename”
17. To unzip a tar.gz file: “tar -xvzf filename”
18. To zip a file or folder, in this case called foo: “zip foo.zip foo.html” or “zip -r foo.zip foo/”
19. To transfer one server to another or one site to another: wget http://www.yourhost.com/folder_name.tar”
System specific commands:
20. commands are distribution specific, such as apt in Debian: apt-get install
General:
1. To show your current location pwd
2. To find out which user you are: whoami
3. To display current server date and time: date
4. To open the manual pages for commands: man
5. quit or exit an application: q
Directories:
6. To list folders or directories use: “ls” or “dir”
7. To make a directory: mkdir
8. To change directories: “cd /path/to/your/directory”
9. To delete a directory: “rm -rf directoryname”
10. To change up one directory: “cd ..” (two directories: “cd ../..”)
Files:
11. To Copy a file with: cp
12. To move a file, also used to rename files: mv
13. To remove a file: rm
14. To upload a file: “wget http://www.yourhost.com/yourfile.tar.gz”
15. To delete a file: “rm filename”
16. To unzip a zip file: “unzip filename”
17. To unzip a tar.gz file: “tar -xvzf filename”
18. To zip a file or folder, in this case called foo: “zip foo.zip foo.html” or “zip -r foo.zip foo/”
19. To transfer one server to another or one site to another: wget http://www.yourhost.com/folder_name.tar”
System specific commands:
20. commands are distribution specific, such as apt in Debian: apt-get install
Abonnieren
Posts (Atom)