Magazine posts:
Files available:
38
293
Hacking Library
Main page
Library magazine
Text archives
Trojans related
Password related
Messenger related
IRC related
Virus related
Web bug scanners
Nukers/Flooders
IP Scanners
Security area
Webmasters area
Missing files
About us
Contact us
Links / Affiliates
Underground Libra
DDLbyte.com
Macintosh UG List
Warez Downloads
Progenic Toplist
r00t Security
Suck-O Community
haxxx.net
Direct Downloads
Hacking Library password
 Global tip
Library
Donate to unlock the passworded files and support us!
Library
 
 Most recent posted
  Google's spyware! Aug/8
  Virus spreadingFeb/18
  Setup iStealer for PHP loggingFeb/13
  Password grabbersFeb/12
  Keylogging passwordsFeb/11
  Steal logins with fake sitesAug/3
  Hidden programs in WindowsJul/21
  DoS Attack tutorialJul/18
  SQL Injections tutorialJul/18
  Another phishing tutorialJul/18
  Phishing tutorial Jul/18
  Defacing a website Jul/18
  Whats is hacking? How its done?Jul/18
  Telnet hacking tutorialJul/17
  Simple cmd.exe tricks for startersJul/17
  Hacking a Network ComputerJul/17
  Basics of PHPJul/10
  What is a hacker? Jul/10
  Find an IP address Jul/10
  How a trojan/rat works in few words Jul/10
  How to catch a hacker Jul/10
  Few words about exploits Jul/10
.
Library magazine
PHP is a server side scripting language that makes it easy to create dynamic websites.
The code is similar to Java and C++ so if you know one or both of these languages you should 
be able to pick up PHP fairly easily.

To use PHP you must either upload your site to a server that supports PHP or set up your own 
server. Unless you have a fast internet connection uploading your files for testing all the 
time will most likely not be a very good option for you. A good option is to have your own 
server on your local workstation. The best way to do this would be to use Windows 2000 or XP
with Internet Information Services installed. You can then download the PHP engine and install
it on your computer. This will allow you to test your pages quickly. However there are other 
ways of doing this such as the Apache sever.

PHP is an embedded language. This means that you can embed code within a HTML document. There 
are a few ways in which this can be done:

<? echo ”Test Message”; ?>

This is the most common way of embedding code, but it may cause problems if your code must 
co-exist with XML.

Another common way to embed is:

<?PHP echo ”Test Message”; ?>

I recommend using this method for embedding for compatibility with other systems.

There are two other alternate methods but these two aren’t used very often:

<% echo ”Test Message”; %>

By default this method is turned off, and I do not recommend using it.

The final way is similar to putting JavaScript in your page:

<SCRIPT LANGUAGE=”php”>
     echo ”TestMessage”;
</SCRIPT>

Every file you create that contains PHP code you must make sure the extension is the PHP 
extension set on your server. I usually just use .php, but some people say that you should use
 the PHP version .php3 or .php4. I have never had any problems but there may be some issues 
with other servers which is why I still mentioned it.

As I mentioned earlier PHP’s syntax comes from languages like C++. This means that you can 
use: // /* */ and even # for comments. Also the structure of things like for loops are 
similar, but variables in PHP are different.
All variables have a $ sign at the start and is followed by an alphabetic or underscore 
character. No data type declarations are necessary and you do not have to initialise the 
variables:
<?
$name;
$name=”John”;
echo “My name is $name”;
?>

OUTPUT:
     My name is John

Notice how I can just put the variable name inside the output string.
Double quotes will be checked for variables and escape sequences.
If you do not want this to happen you would use single quotes:

<?
$name;
$name=”John”;
echo ‘My name is $name’;
?>

OUTPUT:
     My name is $name

If you do wish to specify the data type for a variable you can use type casting:

$number = (int) = “342asd”;

This will create an integer value of 342.
The types PHP supports are as follows:

(int), (integer)                  – Cast to integer
(real), (double), (float)     – Cast to float
(string)                             – Cast to string
(array)                              - Cast to array
(object)                             - Cast to object


Selection is something that is very important to know for every language. Selection in PHP is
very similar to C++ and Java. We will fist start with the If statement:

if(expression){
     statements
}

This is a basic If statement. It is a bit hard to understand this way because we have nothing
to test for so I will expand and put some sample data in.

if($name == “John”){
     echo “John is the creator of this tut”;
}

Now with this data in it will say if the value in $name is equal to the string “John” then do
the code within the braces.
We can then further expand on this to do something else if the value is not true:

if($name == “John”) {
     echo “John is the creator of this tut”;
} else {
     echo “$name is not the creator of this tut”;
}

This code will do the same as previous but it will now output the second echo statement if it 
is not true.
Say the value of $name is “Bob”. It will go through and say is $name the same as “John”. No 
its not so we will go to else and output “Bob is not the creator of this tut”.
Getting confused? I hope not because we are going to expand on this code again and test for a 
second name.

if($name == “John”){
     echo “John is the creator of this tut”;
} else if($name == “Bob”){
     echo “I don’t know any Bob”;
} else {
     echo “$name is not the creator of this tut”;
}

This code again does the same as previous but it will test for two conditions.
Say the value of $name is still “Bob”. It will look at the first condition. Is the value in 
$name the same as “John”? No, So go to the next if. Is the value in $name the same as “Bob”? 
Yes, output “I don’t know any Bob”.
You can keep expanding on this testing for as many conditions as you wish.

Just a note if you have only one line after you if statement you don’t have to have braces:

if($name == “John”)
     echo “John is the creator of this tut”;

But if you want two or more statements you must have braces. I just find it easier to use 
braces all the time.

Also you may be wondering why I am using “==”. Well if you think to where you assign a value:

$name = “John”;

That is how you assign a value, so if you had:

if($name = “John”)

You would be trying to assign a value and you would receive an error.
Other comparisons you can do are things like &&, ||, >, <
I will explain the Boolean operators in a later tutorial.

The next selection statement is the Switch. The basic syntax is as follows:

switch(expression) {
case expression:
     statements
     break;
default:
     statements
     break;
}

Again this is a bit hard to follow so I will put some meaningful code in to help:

switch($name) {
case “John”:
     echo “John is the creator of this tut”
     break;
default:
     statements
     break;
}

This will basically do the same sort of thing as an if statement. If the value in $name is 
“John” then output “John is the creator of this tut”. If not then go to the next case, in this 
example the next case is the “default:”. This acts in a similar way to “else” in an if 
statement.
Also just like if statements you can expand and test for more values. To do this all you need 
to do is to add in more case statements.

switch($name) {
case “John”:
     echo “John is the creator of this tut”
     break;
case “Bob”:
     echo “I don’t know Bob”
     break;
default:
     statements
     break;
} 
Library
Library