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

    • I’ve seen tools like Find Person Name by Photo come in handy for creators who want to understand their audience better or spot fake accounts trying to piggyback on their growth. Pairing something like that with a solid SMM panel can make your workflow feel way smoother, especially if you're trying to grow without getting tangled in guesswork.
    • Join our discord: https://www.lineage2.cz/discord  
    • You should buy it then I’ll make a discount  
    • Hi everyone,   In 2014, I completely stepped away from developing L2 servers and doing L2J-related work. Since then, I’ve only opened this server about once a year and helped a few servers and individuals for free. I haven’t taken on any paid L2J work since then.   LINEAGE2.GOLD is a project that has reached about Season 6. The first season launched at the end of 2020 and was a fully rebuilt Gold-style server on the Classic client (protocol 110). It featured many custom systems and enhancements. After several seasons, I decided to abandon the Mobius-based project and move to Lucera, as my goal was to get as close as possible to Interlude PTS behavior while still staying on the L2J platform.   The current project was once again completely rebuilt, this time on the Essence client (protocol 306), and is based on Lucera. Because of that, acquiring a license from Deazer is required.   My Lucera extender includes, but is not limited to: Formulas.java Basic anti-bot detection, which proved quite effective, we caught most Adrenaline users using relatively simple server-side logic, logged them, and took staff action. Simple admin account lookup commands based on IP, HWID, and similar identifiers. In-game Captcha via https://lineage2.gold/code, protected by Cloudflare, including admin commands for blacklisting based on aggression levels and whitelisting. Additional admin tools such as Auto-Play status checks, Enchanted Hero Weapon live sync, force add/remove clans from castle sieges, item listeners for live item monitoring, and more. A fully rewritten Auto-Play system with support for ExAutoPlaySetting, while still using the Auto-Play UI wheel, featuring: Debuff Efficiency Party Leader Assist Respectful Hunting Healer AI Target Mode Range Mode Summoner buff support Dwarf mechanics Reworked EffectDispelEffects to restore buffs after Cancellation. Raid Bomb item support. Reworked CronZoneSwitcher. Prime Time Raid Respawn Service. Community Board features such as Top rankings and RB/Epic status. Custom systems for Noblesse, Subclasses, support-class rewards, and much more.   Depending on the deal, the project can include: The lineage2.gold domain The website built on the Laravel PHP framework The server’s Discord Client Interface source Server files and extender source The server database (excluding private data such as emails and passwords)   I’m primarily looking for a serious team to continue the project, as it would be a shame to see this work abandoned. This is not cheap. You can DM me with offers. If you’re wondering why I’m doing this: I’ve felt a clear lack of appreciation from the L2 community, and I’m not interested in doing charity work for people who don’t deserve it. I’m simply not someone who tolerates BS. Server Info: https://lineage2.gold/info Server for test: https://lineage2.gold/download Over 110 videos YouTube playlist: https://www.youtube.com/watch?v=HO7BZaxUv2U&list=PLD9WZ0Nj-zstZaYeWxAxTKbX7ia2M_DUu&index=113
  • 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..

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock