Mar 07, 2022

PHP introducing tutorial

Hello guys, in this tutorial I am going to give you a quick idea about php language. We use php for make interactive band dynamics web pages. Php is a server side language. So it runs on the server and gives plain HTML output to the client. Actually the name php is an acronym for Hypertext Preprocessor. It is said that PHP was originally stand for personal home page. :-)

Why you learn PHP

If you are planning to learn penetrating testing , ethical hacking , cyber security analysis or any thing related to web application security you will need to take a good understand in PHP. Sometimes we need to make a quick php shell for access a server so we must have some knowledge of php. If you want to understand what's SQL injection or OS command execution you should learn php to get an idea of how back-end server handle the user input. Also if you want to be a web developer php is a must to learn. Take HacksLand for an example. This site is based on a modified version of WordPress cms. Did you see the latest posts section on index page. Do you think I am using a gallery plugin for this. No buddy. It is a simple php script.
function hl_recent_posts() {
    $hl_recent_posts = new WP_Query();
        while ($hl_recent_posts->have_posts()) : $hl_recent_posts->the_post(); ?>

            <div class="responsive">
                <div class="gallery">
                    <a href="<?php esc_url(the_permalink()); ?>"><img src = <?php the_post_thumbnail_url(); ?>  width="120" height="100"></a>
                    <div class="desc"><a href="<?php esc_url(the_permalink()); ?>"><?php esc_html(the_title()); ?></a></div>

        <?php endwhile;
    echo '<div class="clearfix"></div>' ;
    echo '<div style="padding:6px;">' ;

No, As a beginner I don't expect you to understand the full php code above. What I wanted to show you is how it's look like a php code snippet. For syntax highlighting there are many plugins. But all of them load prism.js and css files on every page. Even in index page.That cause to increase the page size. So I use a php script with prismJs that load only when a code is detected. I don't prefer using plugins for every things. Because they slow down website. :-( Also when we use ready made WordPress themes we can't get our desired look and functions. So what I wanted to say you is if you have a little php knowledge you can build your own customized web pages. When we comparing with a programming language like C , there are no much deep things to learn in php. If you have some little knowledge in how a general programming language work , you can simply learn php. Anyway we are going to learn php from basics. So let's see how you can write and test a php script. I think I don't want to tell you how to write a code. You can use sublime , nano , atom or whatever you like. The extension you may want to save your code is .php. Hear we can see a sample php script. Yes we can call it a hello world program.
echo "welcome to HacksLand" ; //we used echo for printout the string.

/*hear you can see a multi line comment 
that wrap to multiple lines.*/
  Isn't it so simple? There are two types of comments in above example. wait. This is not the only way you can write a php code. You can embed a php snippet inside html. But extension must be .php and not .html. Let's see an example. Now writing php codes is OK. Next we want to run these codes in a server. But how we do it? If you are using a distro like Debian /Kali or Ubuntu you don't need to do anything. Php , server and a SQL management system are already installed on your OS. Just copy your code into /var/www/html and star apache or nginx server. Then open Firefox and browse Your web page. But you are using windows you want to install wamp ox xamp . Both of them contain php, apache etc for build a complete web server on your windows host. In next tutorials I'll explain more deep things in PHP. Thank you for reading. :-)
Aug 12
How to use python as a http server

Hello guys, Today I'm hear with another quick tutorial. in this one I'll explain you how we can....

Mar 12
Termux command list

Termux is a terminal emulator application for mobile devices. In this document, we are going to....

Oct 16
Protostar Stack3 Tutorial

Hello there in this article we are going to see how we can exploit and win protostar stack 3 level.....

Replying to 's comment Cancel reply
Thilan Danushka Dissanayaka

Thilan Dissanayaka

Hi, I'm Thilan from Srilanka. An undergraduate Engineering student of University of Ruhuna. I love to explorer things about CS, Hacking, Reverse engineering etc.