Jump to content

Recommended Posts

Posted

Here we're going to learn the basics of the PHP web scripting langauge in a very in depth tutorial. This includes variables, displaying text on a page, simple things like that. Note: This is not an experienced scripter tutorial. If you script PHP already, this tutorial is not for you. And if it was graphics, I'd make it an image, but it's not, so this post will only contain BBCode, and plain text. So here we go:

 

File format:

.php - The main PHP file extension.

.phps - A file format that displays the actual code without parsing it to the webserver (meaning if you have a news system, it would display the code you made, not the actual system).

 

Tools I use:

1. jEdit script editor - Found here

2.. The windows FTP system, or SmartFTP/leech FTP. It's honestly you're choice which one you prefer to use. And you can always check Google.

3. And last but not least, I use my secret directory on my website to see/test the results of my PHP scripts.

 

Table of content:

I - PHP Blocks

II- Display text

III - Comments

IV - Variables

V - Operators

VI - Else If

 

Now, let's start, shall we?

 

I - PHP Blocks:

There are two mostly used PHP blocks, and possibly a couple more if you look around the web. These are the two main ones:

 

<?php
code here
?>

and:

<?
code here
?>

 

If you plan on distributing any scripts you make, I advise you use the first block I showed you.. Some people just like it more. But if you're gonna keep your scripts private, it's entirely up to you; even though there's not really a difference.

 

II - Display text

As most of you reading this tutorial probably know HTML, CSS, XHTML, or something along those lines. When you use those, those are for design, making your website look good, etc. PHP is a scripting langauge, and is not entirely based upon looks and text, so you have to use the echo and print statement for displaying text. Echo is used more than print though, and people understand it off the back. Print is usualy recognized better in C++ code, and thing similar to that. Also remember, when creating a PHP script, use the HTML tags for defying the HTML, and for the body. The echo statement would look ike this:

 

<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>

 

On a webpage, that would display "Hello World". You may/should have noticed the semicolon at the end of the command line. When you end a instruction.

 

III - Comments

If you ever plan on distributing your scripts to place like.. Pixel2Life, HotScripts, or anywhere else where they have PHP scripts that users give in up for download, it's in your best interest to use comments. Comments are extremely helpful when people are reading your code to use it, or trying to learn from it, as well as also helps you keep notes. It explains what the code does without parsing any information from it in to the script. So it doesn't display at all, but is still viewable in the file.

 

They have two main comments:

 

<html>
<body>
<?php
/*
This is a multiline comment
*/

// This is a single line comment

#Shell style comment
?>
</body>
</html>

 

If you uploaded that on to your web server, the page would be completely blank. Those are the two main comments used in the PHP scripting langauge.

 

IV - Variables

In PHP, variables are used to store values, really. You can make a variable, display the variable's value on a web page, and a couple of other things. But right now we're going to focus on setting a variable's value, and then displaying it on a page. Remember: A variable always has a $ symbol infront of it.

 

Setting a variable:

 

<?php
$var = 'my first variable';
?>

 

Now $var would have the value of the text "this is my first variable". Also, two-word variables have the first letter lowercase, and the second word capital. Like this:

 

<?php
$myVar = 'my first two-world variable';
?>

 

Now the two word variable, $myVar, would have the value of the text "my first two-world variable".

 

Now we're going to display the variable using the echo statement:

 

<?php
$var = 'my first time displaying a variable'
echo $var;
?>

 

On your web page, that would display the text "my first time displaying a variable".

 

Say you'd like to display two variables, you'd do it with the dot operator. Like so:

 

<html>
<body>
<?php
$var = 'variable one'
$var2 = 'variable two'
echo $var . " " . $var2;
?>
</body>
</html>

 

That would display the value of $var, then $var2.

 

V - Operators

 

I'm just going to list all of the operaters used in the PHP scripting langauge (operater followed by action):

 

+ - Addition

- - Subtraction

* - Multiplication

/ - Division

% - Division remainder

++ - Inceremt

-- - Decrement

== - Is equal to

!= - Isn't equal to

> - Is greater than

< - Is less than

>= - Is greater than or equal to

<= - Is less than or equal to

&& - And

|| - Or

! - Not

 

VI - Else and If

Else and if are used in most aspects of scripting with PHP. They are used to test values (as well as other things), and then do an action when something is determined. In my example, I'm gonna use three options, and when you use three, or more.. It's if, elseif (depending on how many other options), then else is the final option.

 

Now, we're gonna try this:

 

<html>
<body
<?php
$ren='render';
if ($ren=="good")
echo "Good job!";
elseif ($ren=="okay")
echo "Not bad";
else
echo "No comment";
?>
</body>
</html>

 

Credits: Tyro

Posted

Nice Share Seeya!!! Keep up!!!!

That's Good for people who start learning php....

Posted

nice share man i was thinking to start learn about the programing but i didnt know from where to start i think that i will start from here :P

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ## [1.4.0] - 2026-01-28   ### ✨ New Features - **Vote System**: Lineage 2 servers can now use our vote–reward system. Players vote on the website and claim rewards in-game (1 vote = 1 claim) - **Vote Page**: On each server’s page (`/servers/<server>`), a **“Vote for Server”** button opens a dedicated vote page with cooldown info and optional Turnstile verification - **By Votes View**: The **“By Votes”** tab on the main page shows **actual vote counts** per server - **API Documentation**: New **API Docs** page at `/docs` (and footer link) with HMAC auth, endpoints, and examples for game server integration - **Vote API (My Servers)**: Server owners can open **“Vote API”** in My Servers to manage credentials, cooldown, allowed IPs, and open the docs   ### 🔄 Improvements - **Server Pages**: Single-server data is cached and loads faster; server pages can be opened by ID or by name (e.g. `/servers/my-server-name`) - **API Root**: Visiting the API root redirects to the docs URL configured in admin (default: site docs page) - **Admin Panel**: New **“Vote System”** tab for global settings (Turnstile, API security, default cooldown, docs URL)   ### 🔐 Security & Reliability - Turnstile (CAPTCHA) support for vote submissions to reduce abuse - HMAC-protected game server API for secure vote check/claim and stats
    • "I recently purchased the account panel from this developer and wanted to leave a positive review.   The transaction was smooth, and the developer demonstrated exceptional professionalism throughout the process.   What truly sets them apart is their outstanding post-sale support. They are responsive, patient, and genuinely helpful when addressing questions or issues. It's clear they care about their customers' experience beyond just the initial sale.   I am thoroughly satisfied and grateful for the service. This is a trustworthy seller who provides real value through both a quality product and reliable support. 100% recommended."
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • ⚙️ General Changed “No Carrier” title to “Disconnected” to avoid confusion after abnormal DC. On-screen Clan War kill notifications will no longer appear during Sieges, Epics, or Events. Bladedancer or SwordSinger classes can now log in even when Max Clients (2) is reached, you cannot have both at the same time. The max is 3 clients. Duels will now be aborted if a monster aggros players during a duel (retail-like behavior). Players can no longer send party requests to blocked players (retail-like). Fixed Researcher Euclie NPC dialogue HTML error. Changed Clan leave/kick penalty from 12 hours to 3 hours. 🧙 Skills Adjusted Decrease Atk. Spd. & Decrease Speed land rates in Varka & FoG. Fixed augmented weapons not getting cooldown when entering Olympiad. 🎉 Events New Team vs Team map added. New Save the King map added (old TvT map). Mounts disabled during Events. Letter Collector Event enabled Monsters drop letters until Feb. 13th Louie the Cat in Giran until Feb. 16th Inventory slots +10 during event period 📜 Quests Fixed “Possessor of a Precious Soul Part 1” rare stuck issue when exceeding max quest items. Fixed Seven Signs applying Strife buff/debuff every Monday until restart. 🏆 Milestones New milestone: “Defeat 700 Monsters in Varka” 🎁 Rewards: 200 Varka’s Mane + Daily Coin 🌍 NEW EXP Bonus Zones Hot Springs added Varka Silenos added (hidden spots excluded) As always, thank you for your support! L2Elixir keeps evolving, improving, and growing every day 💙   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..