If yousa Africanized sandal and high water corduroy wearin' craigslist scammin' ass muthafucka who believes PHP can be learned in 24 hours, get the fuck out of my thread.
It occurred to me that there are more than a few of you kats on the board with a genuine interest in dynamic web development beyond out the box CMSs and Forums. PHP is the foundation of dynamic web development.
It is also becoming more and more obvious that there are a slew of fraudulent ass clowns disseminating piss poor information about web development, such as writing half assed code, relying soley on GUIs and having you spend money on hacks from India. Janitor type niggas passing themselves off as web authorities. Vegas hookers workin' in Best Buy trying to get you hooked on GUIs. Black ass niggas who thinks building computers makes them experts on all things code.
I have over a decade of web programming under my belt. In this thread I'm not going to take tutorials from other books and post them as if they were mine. We're gonna get code FROM SCRATCH.
Control the source code, control EVERYTHING. Why is it imperative that you rookies know line for line what your code does? You hear the term "Programming Language". It's just that, a LANGUAGE. Imagine going through life not understanding the English language (I believe most of you don't, but that's for another thread). Imagine you had an idea for a story. You can't understand English so you hire an assclown from India to write it for you. How do you know if in fact he's writing your story? How do you know he's using proper grammar? How do you know? You don't. Control your code, CONTROL YOUR IDEA!
If you are one of these algebra flunkin ass niggas, get out of my thread. If you are one of the Colin Powell type niggas, leave my thread. If yousa Best Buy Janitor ass nigga, get out of my thread. If yousa whining ass "it's too hard" type nigga, leave my thread. If you don't understand f(y) = 2xy get out. If you from the south, get outa my thread. If you're a faggot, leave my thread immediately. If yousa bitch nigga, get the fuck outa my thread.
I'm not doing this for the community. I don't give a fuck about the kids nor I don't care about the inner city negroid. There ain't enough Black developers out there, and there is no excuse.
This thread is for kats who are serious. I'm going to cut some years off your learning curve. Now this thread is meant as a SUPPLEMENT to php.net and whatever books you buy. I'm here to break shit down to layman's/real world terms for you to gain a better understanding. That doesn't mean that you are exempt from learning from php.net, that is mandatory. Now while my knowledge of PHP is advanced, there are levels way above advance, so I don't know EVERYTHING about PHP, but I sure as hell know more than enough to put you up on "Markus Frind" type game (look him up).
Through out the day today I'll be covering:
What is PHP
How to Install PHP
How to install MySQL
Procedural vs. OOP
MVC framework
Variables.
Software needed for this ongoing tutorial:
PHP
MySQL
phpmyadmin
An advanced text editor such as Notepadd++, Coda, Textmate, or Dreamweaver.
$bgol = 'this is bgol'; // proper use
$_bgol = 'this is bgol'; // improper, only reserved for super global variables
$4bgol = 'this is bgol'; //not valid starts with a number
$bgol = 'this is bgol'; // A string
$bgol = 2 * 7; //A calculation
$bgol = 2 * 7 . ' this is bgol'; // a calculation and a string
$bgol = 'this is bgol ';
$math = 2 * 7;
$results = $bgol . $math;
echo $results; //this is bgol 14
$bgol = 'this is bgol ';
$math = 2 * 7;
$results = $bgol + $math;
echo $results; // 14
$bgol = array(
'string' => 'this is bgol',
'math' => 2*7,
);
echo $bgol['string'], $bgol['math']; //Outputs: this is bgol 14
How come you are being nice, is someone giving you free pussy?
Variables
Arrays are special data types. Despite of other normal variables an array can store more than one value. Let's suppose you want to store basic colors in your PHP script. You can construct a small list from them like this:
Color list:
* red
* green
* blue
* balck
* white
It is quite hard, boring, and *bad idea to store each color in a separate variable. It would be very nice to have the above representation almost as it is in PHP. And here comes array into play.
The array type exists exactly for such purposes. So let's see how to create an array to store our color list.
<?php
$red = red;
$green = green;
$blue = blue;
$black black;
$white = white;
?>
There are more ways to create an array in PHP. Maybe the most easiest way to create our color list array is the following:
Code:
PHP:$colorList = array("red","green","blue","black","white");
another solution is to *initialize array elements one-by-one as follows:
PHP:$colorList[0] = "red"; $colorList[1] = "green"; $colorList[2] = "blue"; $colorList[3] = "black"; $colorList[4] = "white";
If you don't want to bother about numbering - I will explain it later - you can create your array as this:
PHP:$colorList[] = "red"; $colorList[] = "green"; $colorList[] = "blue"; $colorList[] = "black"; $colorList[] = "white";
As you can see this is almost similar to the other but here we didn't write any number between the square brackets. In this case PHP makes the numbering internally from 0 to 4. This function is the so called auto-incremented keys.
echo $sky;
Notice: Undefined variable: sky in /test.php on line 3
In the last step we have created an array. It is not important which solution you choose the result is the same. It's nice but how you can use the data in the array. For example how to display the elements? There are more ways to do this. Let's see the possibilities.
If you want only display one element of the array then you can just write the following code:
PHP:echo $colorList[0];
This code will display the text "red". However you may want to display all elements in the array. You can write a *loop and display them like this:
PHP:for ($i=0;$i<=4;$i++){ echo $colorList[$i]; }
It is quite easy. However it is not the best solution as the number of element is hard coded. There is a much better way to display all elements of an array. You can use a foreach loop as this:
PHP:foreach ($colorList as $value) { echo $value; }
If you want to display array content for debugging purposes then you can use 2 built in PHP functions. These are the print_r and var_dump. These functions displays the array as key-value pairs. Besides this var_dump also displays variable information. You can use them as follows:
PHP:print_r($colorList); echo ""; var_dump($colorList);
In the next step we will learn about associative arrays.
for ($i=0;$i<=4;$i++){
echo $colorList[$i];
}
for ($i=0;$i<=count($colorList);$i++){
echo $colorList[$i];
}
echo '<pre>', print_r($colorList), '</pre>';
In general PHP arrays are maps, which means that it is a type that maps values to keys. In our example it means that where the key is 0 there the value is "red" and where the key is 1 there the value is "green". However you have the possibility to use more meaningful keys. Associative array means that you can assign an arbitrary key to every value. Associative arrays are sometimes referred to as dictionaries. Our colorList array can be defined as associative array like this:
PHP:$colorList = array("apple"=>"red", "grass"=>"green", "sky"=>"blue", "night"=>"black", "wall"=>"white" );
You have to remember that array keys are case-sensitive, but type insensitive. It means that 'a' differs from 'A' but '1' is the same as 1.
So, the array above can be defined (created) one-by-one elements like this:
PHP:$colorList["apple"] = "red"; $colorList["grass"] = "green"; $colorList["sky"] = "blue"; $colorList["night"] = "black"; $colorList["wall"] = "white";
And you can display the content similar to the normal array, but here you need to use the string value instead of the number.
PHP:echo "The sky is ".$colorList["sky"] ." and the grass is ".$colorList["grass"];
You can mix your array and use numbers and strings in the same list like this:
PHP:$colorList["apple"] = "red"; $colorList[5] = "green"; $colorList["sky"] = "blue"; $colorList["night"] = "black"; $colorList[22] = "white";
As you can see even the numbers can be any so you don't have to make it continuous. However be aware of using such mixed arrays as it can result errors.
$colorList["apple"] = "red";
$colorList[5] = "green";
$colorList["sky"] = "blue";
$colorList["night"] = "black";
$colorList[22] = "white";
$colorList = array(
'apple' => 'red',
'5' => 'green',
'sky' => 'blue',
'night' => 'black',
'22' => 'white',
);
As each element value of the array can be any type it means that it can be other array as well. If an array element value is an other array then this is a multidimensional array. Of course the internal array values can be arrays as well and so on. You can define 10 dimensional (or more) array if you want.
Creating a multidimensional array is as almost simple as the normal array. Let's see an example:
PHP:$myLists['colors'] = array("apple"=>"red", "grass"=>"green", "sky"=>"blue", "night"=>"black", "wall"=>"white" ); $myLists['cars'] = array("BMW"=>"M6", "Mercedes"=>"E 270 CDI", "Lexus"=>"IS 220d", "Mazda"=>"6", "Toyota"=>"Avensis" );
To acces and display an element in the multidimensional array you just extend the key list as follows:
PHP:echo $myLists['cars']['Toyota'];
Of course you can define normal, mixed and associative multidimensional arrays.
$myLists['cars'] = array("BMW"=>"M6",
"Mercedes"=>"E 270 CDI",
"Lexus"=>"IS 220d",
"Mazda"=>"6",
"Toyota"=>"Avensis"
);
$myLists['cars'] = array(
'BMW' => 'M6',
array('colors' => 'red', 'green', 'yellow'),
'Mercedes' =>'E 270 CDI', ,
array('colors' => 'orange', 'blue', 'purple'),
'Lexus' => 'IS 220d',
array('colors' => 'red', 'green', 'burgundy' =>
array('light burgundy', 'dark burgundy'),
),
'Mazda' => '6',
'Toyota' => 'Avensis'
);
*String Values
I use single quotes instead of double quotes.
$colorList['night'] = $colorList["night"]
Brotha JD, as a rule of thumb I always use single quotes instead of double quotes. Especially since double quotes can mess ya up when mixing in HTML. What would you recommend for the young homies?
<html>
<head>
<title>HTML Page</title>
<script type="text/javascript">
alert('This is a Javascript Alert');
</script>
</head>
<body>
<div>My English teacher told me I can't write sentences with contractions because it is improper.</div>
</body>
</html>
echo '
<html>
<head>
<title>HTML Page</title>
<script type="text/javascript">
alert(\'This is a Javascript Alert\');
</script>
</head>
<body>
<div>My English teacher told me I can\'t write sentences with contractions because it is improper.</div>
</body>
</html>';
echo '
<html>
<head>
<title>HTML Page</title>
<script type="text/javascript">
alert("This is a Javascript Alert");
</script>
</head>
<body>
<div>My English teacher told me I can\'t write sentences with contractions because it is improper.</div>
</body>
</html>';
concatenation |kənˌkatnˈā sh ən|
noun
a series of interconnected things or events
<?php
$a = 'I am ';
$b = 'posting ';
$c = 'on bgol today.'
$d = $a . $b . $c;
echo $d; // I am posting on bgol today.
?>
<?php
$a = 'I am ';
$b = 'posting ';
$c = 'on bgol today.'
echo $a, $b, $c; // I am posting on bgol today.
?>
echo $a . $b . $c;
$d = $a . $b . $c;
echo $a, $b, $c;
$d = $a, $b, $c; //This will generate an error.
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
constant |ˈkänstənt|
adjective
occurring continuously over a period of time : the pain is constant.
• remaining the same over a period of time : the company has kept its prices fairly constant.
• (of a person) unchangingly faithful and dependable.
See note at resolute .
define('LEROY_SLAP_NUTZ','Is and forever will be a faggot.');
echo LEROY_SLAP_NUTZ; // Outputs: Is and forever will be a faggot.
<?php
$color = 'blue';
?>
<?php
include('test.php');
echo $color; // Outputs: blue
?>
<form method="post" action="">
<!-- input fields -->
</form>
http://bgol.com/index.php?action=delete;what=faggot;name=leroy
$action = delete;
$what = faggot;
$name = leroy;
Installing PHP, MySQL, and phpMyAdmin on Linux and Windows
I don't know how to do either.
I'm assuming "LAMP" applies to Linux OS by default?
If there are any of you who have successfully installed and run PHP, MySQL, and phpMyAdmin on both these platforms it would be appreciated if you can offer a step to step installation guide like the one I provided for the Mac.
sudo taskel install lamp-server
sudo apt-get install php5
What I need is a good secured PHP login script that I can use at my workplace. I'd like something that has an interface so if an employee leaves the company I can disable their account. Don't really want to have to go into MySQL to delete the record. I've seen some examples on the net but some have been really buggy. Would like to use it with a template within Dreamweaver. Any ideas?
define('url', 'http://127.0.0.1/directory_to_your/tutorial');
$theme = array(
'url' => url . '/Templates',
'default' => array(
'url' => url . '/Templates/default',
'images' => url . '/Templates/default/images',
'style' => url . '/Templates/default/style.css',
),
);
ob_start();
error_reporting(E_STRICT | E_ALL);
require_once('Settings.php');
include_once('Engine/Actions.php');
include_once('Engine/Functions.php');
include_once('Engine/Login.php');
include_once('Engine/Query.php');
include_once('Templates/default/IndexTemplate.php');
ob_flush();
ob_start();
ob_flush();
error_reporting(E_STRICT | E_ALL);
require_once('Settings.php');
include_once('Engine/Actions.php');
include_once('Engine/Functions.php');
include_once('Engine/Login.php');
include_once('Engine/Query.php');
include_once('Templates/default/IndexTemplate.php');
<form method="post" action="">
<fieldset><legend>Register</legend>
<label for="name">Name</label><input type="text" name="name" id="name" />
<br />
<label for="email">Email</label><input type="text" name="email" id="email" />
<br />
<label for="password">Password</label><input type="password" name="password" id="password" />
<br /><br />
<input type="submit" name="register" value="Submit" />
</fieldset>
</form>
echo '<pre>', print_r($_POST), '</pre>';
Can an option be added where if the user forgets their password they can fill out a form or does the script email them their password. Also can the script give them an opportunity to change their password or will they have to contact IT to change it?
If I remember correctly I've seen some passwords stored as md5 format. Sorry if I'm jumping ahead. I really need to understand this because I need to implement this at work right away.