Skip to content

Instantly share code, notes, and snippets.

@ChilliByte
Last active December 16, 2015 15:48
Show Gist options
  • Save ChilliByte/5458077 to your computer and use it in GitHub Desktop.
Save ChilliByte/5458077 to your computer and use it in GitHub Desktop.
-----------------------------------------------------------------------------------------------------------------------------
PHP Notes
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
Echo
-----------------------------------------------------------------------------------------------------------------------------
The "echo" function shows text a, the server does nothing apart from generate a HTML file with the contents
YOU CAN STYLE THIS With CSS HTML OR JS
E.G.: echo("<h1>Hello World!</h1>");
You can put HTML in a php file after ?> but it has to be before <?php
E.G.
<?php echo("Some Random PHP code")>
<p>lorem ipsum dolor sit amet</p>
<?php }; ?>
You can break out of PHP mode at any time, just close with ?> and carry on, when you want to re-enter PHP mode use <?php
-----------------------------------------------------------------------------------------------------------------------------
Get Request
-----------------------------------------------------------------------------------------------------------------------------
Get sends the server a request, and the user can see this request.
E.G. ?i=~/
? starts a Get request then you have a variable name (e.g. i ) then the variable is assigned to something (e.g. ~)
Code for a get request:
<?php echo($_GET['hello']) ;?>
-----------------------------------------------------------------------------------------------------------------------------
Post request
-----------------------------------------------------------------------------------------------------------------------------
Post sends a request to the server, and the user cannot see it, it is usually used for usernames and passwords
E.G. <?php echo($_POST['hello']; ?>
-----------------------------------------------------------------------------------------------------------------------------
Important!
-----------------------------------------------------------------------------------------------------------------------------
PHP Requires ; after each line
-----------------------------------------------------------------------------------------------------------------------------
Request
-----------------------------------------------------------------------------------------------------------------------------
Get requests only listen to the results of a get request, Post request only listen to posts. $_REQUEST WILL LISTEN TO BOTH
E.G. <?php echo($_REQUEST['hello'])?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment