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 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Our sales are ongoing. Bump. 02 July 2025 Telegram: ContactDiscordAccS
    • Our sales are ongoing. Bump. 02 July 2025 Telegram: ContactDiscordAccS
    • just with this extender that I have shared it is not possible to start with c4 client, you have to make some changes to the extender and it works with c4 client perfectly. regarding the updates in this last revision   🔹dll is not packaged with vmprotect   New custom zone types have been added: 🔹 NO_NOBLESS begin MinX=84638 MaxX=92616 MinY=-87170 MaxY=-82018 MinZ=-6000 MaxZ=0 Type=NO_NOBLESS KickOutPos=83007/148057/-3464 end   ▶️ This zone checks if the character is noble. If it does not meet the condition, it will be automatically kicked to the indicated position (KickOutPos). 🔹 CUSTOM_SPAWN_ZONE begin MinX=77275 MaxX=85704 MinY=10122 MaxY=18066 MinZ=-8000 MaxZ=5000 Type=CUSTOM_SPAWN_ZONE OutPos=83007/148057/-3464 Spawns={{82984/18066/-5256}};{{79275/15147/-5248}};{{82922/14263/-5256}};{{83704/10122/-5288}} end ▶️ This zone allows characters, upon death, to respawn with full buff, CP, HP and MP if they press “Fixed”. They will only be able to revive in one of the positions defined in Spawns. 🔧 Both zones are fully configurable from territorydata.txt 🔧 Development Repository (SVN) GX-EXT supports open, collaborative, and professional development. That’s why we provide access to our public SVN repository where you can:   ✅ Compile your own version of the project ✅ Optimize and extend its features ✅ Learn from real production-quality source code   🔒 Delayed access: The repository is always 2 months behind the latest commercial release to prevent unauthorized reselling.   🔗 SVN URL: https://svn.l2servers.com.ar/!/#GX-EXT_INTERLUDE Username: gx Password: gx   You can use tools like TortoiseSVN to download and work with the code.
    • Could you tell me what changed in this update?   more one question: Is it possible to log in through the c4 client instead of interlude? That would be great  
    • ➡ Discount for your purchase: JULY2025 (11% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...

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