Giter Club home page Giter Club logo

kyle mullikin's Projects

php-notes.ph icon php-notes.ph

<html> <head> <title>PHP notes:</title> </head> <body> <? // a php script(php code)goes in this (tag) /*the ECHO property is used to output code. such as down below!, //PHP is a server side programming language used for... and must end with a semicolon(;)*/ echo "helloworld"; //this is a single lined comment //HTML can be added in the php code /*this is a multi lined comment*/ // php practice goes below: //below is php VARIABLES: //VARIABE practice goes below: $name = retro2.0; /*below you are practicing PHP , and php variables. so keep practicing as much php as possible for as long as possible*/ $age = is 18; $goals = "my goals are to become a backend developer, hacker, become a great programmer"; echo = $name + age + $goals; // ouput's "retro2.0 is 18 my goals are to become a backend developer, hacker, become a great programmer" $bestGun = Hk p30l; $fromWhichFilm? = from john Wick; echo = $bestGun + $fromWhichFilm?; //output should be "Hk p30l from john Wick" $girlfriendsName= toshiba/my laptop; $whyILoveHer.. = "i love her because she is always there when i need to take my mind off my crappy life. as well as prepare for my career and dreams/ programming"; echo = $girlfriendsName + $whyILoveHer?; /*`Constants are similar to variables except that they cannot be changed or undefined after they've been defined. Begin the name of your constant with a letter or an underscore. To create a constant, use the define() function: define(name, value, case-insensitive)*/ //example is below define("MSG", "Hi SoloLearners!"); echo MSG; //outputs "hi sololearners" //The example below creates a constant with a case-insensitive name define("MSG", " Hi SoloLearners!", true); echo msg; // Outputs "Hi SoloLearners!" //below is PHP (strings) in both single and double quotes: $string1 = 'fuck you president Trump'// these are single quotes $string2 = "you are a terrible president, and an asshole that should be impeached" //these are double quotes // PHP (integer's) Integer //An (integer) is a whole number (without decimals) that must fit the following criteria: /*- It cannot contain commas or blanks - It must not have a decimal point - It can be either positive or negative*/ $int1 = 42; // positive number $int2 = -42; // negative number $int = 1000; $int = -1000; // A (float), is a number tha has a decimal point. $x = 42.168; //A (Boolean) represents two possible states: TRUE or FALSE. //what does SUM mean? //my response = " " $x = true; $y = false; /*do not forget to solve the question bove in comments a asap*/ // string and integer are put together to determine the sum of two numbers. //string practice goes below: $str = "10"; /*what does sum mean? i'm guessing it means the equivilent to something*/ $int = 20; $sum = $str + $int; echo ($sum); // Outputs 30 $str = "100"; $int = 100; $sum = $str + $int; echo = ($sum); //output should be 200 $str1 = "my name is"; $str2 = "retr02.0"; $sum = $str1 + $str2; echo = ($sum); //output should be "my name is retr02.0" $str1 = "dedsec has givin you the truth."; $str = "do what you will."; $sum = $str1 + $str; echo = ($sum); //output should be "dedsec has givin you the truth. do what you will." $str = "welcome to my clinic \' if you didn't have herpes before well.. you do now' "; $int + $str2 = 100% "herpes"; $sum = $str + $int + $str2; echo = ($sum); ?> //next in Variables is.. VARIABLE SCOPE'S /*PHP variables can be declared anywhere in the script. The scope of a variable is the part of the script in which the variable can be referenced or used.*/ /*PHP's most used variable scopes are local, global. A variable declared outside a function has a global scope. A variable declared within a function has a local scope, and can only be accessed within that function.*/ //Consider the following example. $name = 'David'; function getName() { echo $name; /*the reason it got an ERROR is because THE VARIABLE WAS NOT DEFINED IN THE FUNCTION*/ } getName(); // Error: Undefined variable: name (above code) $feet = 50; function getfeet(); { echo $feet;// output should be =50 } getfeet(); //below is the same as the above('david')just a new name variable $name = 'Marcuss Hollaway'; function getName() { global $name; echo $name;//gets the variable name from within the function(s), prior to the variables //can also output NUMBERS with a variable? } getName(); //Outputs 'David' /*this may be incorrect(the code below) but at the same time it could still run properly*/ /*this is also just a random example of code that i came up with so i'm not sure if it counts as an (undefined Variable : name */) // it is a task to consider researching asap $windows = 10; function getWindows(); global $numberOfWindowsInBackyard; $numberOfHouses = 1;//my house //WITH PHP you can use Variables to specify another Variables name(as shown below) $a = 'hello'; $hello = "Hi!";//this is the output(Hi!) echo $$a; // Outputs 'Hi!' // BELOW IS OPERATORS notes:(as shown below) //ARITJMETIC operators(below) /*very similar to Javascript operators other than slightly different syntax*/ <?php $num1 = 8; $num2 = 6; $week1 = 10; $week2 = 10; //Addition echo $num1 + $num2; //14 echo $week1 + $week2; //20 //Subtraction echo $num1 - $num2; //2 //Multiplication echo $num1 * $num2; //48 //Division echo $num1 / $num2; //1.33333333333 ?> <?php //Modulus(as shown below) $x = 14; $y = 3; echo $x % $y; // 2 ?> //increment and decrement (below) is also part of Modulus: /*The increment operators are used to increment a variable's value. The decrement operators are used to decrement a variable's value.*/ $x++; // equivalent to $x = $x+1; $x--; // equivalent to $x = $x-1; //Increment and decrement operators either precede or follow a variable. $x++; // post-increment $x--; // post-decrement ++$x; // pre-increment --$x; // pre-decrement //The difference is that the post-increment returns the original value before it changes the variable, while the pre-increment changes the variable first and then returns the value. Example: $a = 2; $b = $a++; // $a=3, $b=2 $a = 2; $b = ++$a; // $a=3, $b=3 // ASSIGNMENT operators are below(part of operators) //these are used to write variables to variables(as shown below) $num1 = 5; $num2 = $num1; //for example .. <?php $x = 50; //50 + 100 = 150(the output) $x += 100; echo $x; //these are used to write variables to variables(as shown below) // Outputs: 150(above code example) ?> // assignment operators practice code is below: $a=1000; //output should be 3000 $a += 2000; echo $a; $ b = 2000; //output should be 4000 //2000*2 = 4000 $b +=2000; echo $b; $x = 1.2million; //1.2million + 2million //output should be 3.2million /*this may be an incorrect form of syntax? but to be honest i doubt it's wrong */ $x += 2million; echo $x; //below is just a random example that could be incorrect(be wary) /*this may be an incorrect form of syntax? but to be honest i doubt it's wrong */ $g =2; //output should be 2(two goals=(g)programmer career, and appt in the city ) $g *1 =2; echo $g; $x =100; //output should be 1100 $x += 1000; echo $x; //?? $x = 220; //output should be 320 $x += 100; echo $x; //below is ARRAYS <?php //numeric arrays $names = array.("kyle","christian wolf","cam"); //with integers, strings, and other data types. $myArray[0] = "John"; $myArray[1] = "<strong>PHP</strong>"; $myArray[2] = 21; echo "$myArray[0] is $myArray[2] and knows $myArray[1]"; // Outputs "John is 21 and knows PHP" ?> //numeric arrays practice coding goes below //"of", "or",&& "what" might not belong in the below text/code(be warned) $myArray[0] = "i am tired"; $myArray[1] = "of this life. i must get a programmer job and build up my coding skill asap"; $myArray[2] = " or i will end up just like my mother, and i'll never live in new york, or achieve any of my goals in life"; $myArray[3] = "what is the point of living if your not achieving your goals, or at least living your dream career?"; echo "$myArray[0] of $myArray[1] or $myArray[2] what $myArray[3]"; //outputs arrays 0-3 into a short paragraph(since i wrote a long multiple arrayed message); </body> </html>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.