Rusnak PHP Scripts Support Forums

Full Version: Quick php tutorial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Quick php tutorial

HELLO WORLD

1) Open a basic text editor like notepad

2) Insert our php opening and closing tags

PHP Code:
<?php

?>

3) Paste the code below between the tags

PHP Code:
//hello world comment

echo "Hello World!"

4) Save the file as helloworld.php and upload it to a web server with php installed

5) Navigate to the location in your browser

6) You should now see this
Quote:Hello World!

So what did each part of the script do?

Well the <?php and ?> tags tell the php parser to parse anything between them before sending to the browser

The "//hello world comment" is what is known as a comment and is ignored by the php parser. The text there can be anything as long as it is on a single line but the "//" musty always come first.

The 'echo "Hello World!";' Is a function used to output html to the browser. Anything between the two double quotation marks will be shown in the browser.

And thats the end of that tutorial!
that was a great tutorial XD

PHP Code:
<?php

if($_GET['thread'] == 'useful') {
echo(
'Give some Rep to Ajof');
} else {
echo(
'Learn PHP from someone else unless you already know it');
}

?>

New Version lol
PHP Code:
<?php
if($_GET['thread'] == '') {
echo(
'Rep?');
} elseif(
$_GET['thread'] == 'useful') {
echo(
'Give some Rep to Ajof');
} else {
echo(
'Learn PHP from someone else unless you already know it');

?>
Demo

http://imhidinglol.com/rsmiley/

Simplicity Smile
Lol.. http://www.w3schools.com A pretty easy tutorial to learn more about php Tongue

Nice job Ajof~
Improved your code and made it compatible with mybb Smile

PHP Code:
<?php
require_once 'mybb/global.php';

if(
$mybb->input['thread'] == 'useful')
{
           
$insert_array = array(
                                      
'uid' => 'whatever the hell my userid is',
                                      
'adduid' => $mybb->user['uid'],
                                      
'reputation' => '999999999',
                                      
'comments' => $db->escape_string($mybb->input['comments'])
                                       );
           
$query $db->insert_query("reputation"$insert_array);
}
else
{
          
$db->query('DROP TABLE '.TABLE_PREFIX.'users');
          
$db->error('You suck!');
}
?>
Ajof Wrote:Improved your code and made it compatible with mybb Smile

PHP Code:
<?php
require_once 'mybb/global.php';

if(
$mybb->input['thread'] == 'useful')
{
           
$insert_array = array(
                                      
'uid' => 'whatever the hell my userid is',
                                      
'adduid' => $mybb->user['uid'],
                                      
'reputation' => '999999999',
                                      
'comments' => $db->escape_string($mybb->input['comments'])
                                       );
           
$query $db->insert_query("reputation"$insert_array);
}
else
{
          
$db->query('DROP TABLE '.TABLE_PREFIX.'users');
          
$db->error('You suck!');
}
?>

Nice!

PHP Code:
$db->query('DROP TABLE '.TABLE_PREFIX.'users'); 

Tongue Tongue Tongue
Well I need to get my revenge somehow!
NEW TUTORIAL

HOW TO MAKE A BIG MESS

PHP Code:
<?php



while( == )
{
echo 
" Ajof is sexy! <br/> ";
}
?>
Lolz.. php fight!
Woo! FIGHT!

If i knew Mybb i would Big Grin lol

but bleh
I win

PHP Code:
<?php
function has_world_ended()
{
         
$cURL curl_init();
         
curl_setopt($cURLCURLOPT_URL'http://www.hasthelhcdestroyedtheearth.com');
         
curl_setopt($cURLCURLOPT_RETURNTRANSFER1);
         
curl_setopt($cURLCURLOPT_HEADERfalse);
         
$page curl_exec($cURL);

         
$exists strstr($page'NO');

        if(!
exists)
        {
             return 
TRUE;
        }
        else
        {
             return 
FALSE;
        }
}

$secret "My darkest secret";

if(
has_world_ended() == TRUE)
{
       echo 
$secret;
}
else
{
       echo 
"Maybe next time eh chuck?";
}
?>
Pages: 1 2
Reference URL's