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

    • 亲爱的朋友们,我们很高兴地宣布一个好消息—— 我们正式推出我们的新机器人,用于购买和租用虚拟号码以接收来自任何服务的短信!您是否已经厌倦了其他平台上重复使用或转售的号码? 试试我们的解决方案! 我们的服务允许您接收来自任何主流热门服务的短信。 服务列表包含超过 200 个项目! 短信接收国家:美国 (+1)。我们使用真实的美国实体号码——从未在其他平台上使用过! 目前仅提供短期租用。每个电话号码的租用时长会在购买时显示。 每个号码的价格也会在购买前显示在对应的服务旁。 您还可以为所选服务的号码接收额外短信(接收额外短信无需额外费用)。 若要快速找到所需服务,可使用便捷的搜索功能——只需输入您所需服务的名称即可获得激活号码。 可用支付方式:加密货币、银行卡,以及从我们其他机器人转移余额。 感谢您的信任! 有效链接: 虚拟号码服务:前往 数字商品商店(网站):前往 商店 Telegram 机器人:前往 – 通过 Telegram 信使方便地访问商店。 Telegram 星星购买机器人:前往 – 在 Telegram 中快速且优惠地购买星星。 SMM 面板:前往 – 推广您的社交媒体账户。 我们向您展示当前的促销与特别优惠,用于购买我们平台的商品和服务: 1. 使用促销码 OCTOBER2025(8% 折扣)在十月份于我们的商店(网站、机器人)购物!您也可以使用首次购买促销码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣 —— 注册后在我们网站按以下格式发布用户名:"SEND ME BONUS, MY USERNAME IS..." —— 并将其发布在我们的论坛主题中! 3. 获取 SMM 面板首个试用奖励 $1 —— 只需在我们网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道和星星购买机器人中赠送 Telegram 星星! 新闻: ➡ Telegram 频道:https://t.me/accsforyou_shop ➡ WhatsApp 频道:https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器:https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram:https://t.me/socnet_support ➡ WhatsApp:https://wa.me/79051904467 ➡ Discord:socnet_support ➡ ✉ 邮箱:solomonbog@socnet.store
    • 亲爱的朋友们,我们很高兴地宣布一个好消息—— 我们正式推出我们的新机器人,用于购买和租用虚拟号码以接收来自任何服务的短信!您是否已经厌倦了其他平台上重复使用或转售的号码? 试试我们的解决方案! 我们的服务允许您接收来自任何主流热门服务的短信。 服务列表包含超过 200 个项目! 短信接收国家:美国 (+1)。我们使用真实的美国实体号码——从未在其他平台上使用过! 目前仅提供短期租用。每个电话号码的租用时长会在购买时显示。 每个号码的价格也会在购买前显示在对应的服务旁。 您还可以为所选服务的号码接收额外短信(接收额外短信无需额外费用)。 若要快速找到所需服务,可使用便捷的搜索功能——只需输入您所需服务的名称即可获得激活号码。 可用支付方式:加密货币、银行卡,以及从我们其他机器人转移余额。 感谢您的信任! 有效链接: 虚拟号码服务:前往 数字商品商店(网站):前往 商店 Telegram 机器人:前往 – 通过 Telegram 信使方便地访问商店。 Telegram 星星购买机器人:前往 – 在 Telegram 中快速且优惠地购买星星。 SMM 面板:前往 – 推广您的社交媒体账户。 我们向您展示当前的促销与特别优惠,用于购买我们平台的商品和服务: 1. 使用促销码 OCTOBER2025(8% 折扣)在十月份于我们的商店(网站、机器人)购物!您也可以使用首次购买促销码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣 —— 注册后在我们网站按以下格式发布用户名:"SEND ME BONUS, MY USERNAME IS..." —— 并将其发布在我们的论坛主题中! 3. 获取 SMM 面板首个试用奖励 $1 —— 只需在我们网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道和星星购买机器人中赠送 Telegram 星星! 新闻: ➡ Telegram 频道:https://t.me/accsforyou_shop ➡ WhatsApp 频道:https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器:https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram:https://t.me/socnet_support ➡ WhatsApp:https://wa.me/79051904467 ➡ Discord:socnet_support ➡ ✉ 邮箱:solomonbog@socnet.store
    • 亲爱的朋友们,我们很高兴地宣布一个好消息—— 我们正式推出我们的新机器人,用于购买和租用虚拟号码以接收来自任何服务的短信!您是否已经厌倦了其他平台上重复使用或转售的号码? 试试我们的解决方案! 我们的服务允许您接收来自任何主流热门服务的短信。 服务列表包含超过 200 个项目! 短信接收国家:美国 (+1)。我们使用真实的美国实体号码——从未在其他平台上使用过! 目前仅提供短期租用。每个电话号码的租用时长会在购买时显示。 每个号码的价格也会在购买前显示在对应的服务旁。 您还可以为所选服务的号码接收额外短信(接收额外短信无需额外费用)。 若要快速找到所需服务,可使用便捷的搜索功能——只需输入您所需服务的名称即可获得激活号码。 可用支付方式:加密货币、银行卡,以及从我们其他机器人转移余额。 感谢您的信任! 有效链接: 虚拟号码服务:前往 数字商品商店(网站):前往 商店 Telegram 机器人:前往 – 通过 Telegram 信使方便地访问商店。 Telegram 星星购买机器人:前往 – 在 Telegram 中快速且优惠地购买星星。 SMM 面板:前往 – 推广您的社交媒体账户。 我们向您展示当前的促销与特别优惠,用于购买我们平台的商品和服务: 1. 使用促销码 OCTOBER2025(8% 折扣)在十月份于我们的商店(网站、机器人)购物!您也可以使用首次购买促销码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣 —— 注册后在我们网站按以下格式发布用户名:"SEND ME BONUS, MY USERNAME IS..." —— 并将其发布在我们的论坛主题中! 3. 获取 SMM 面板首个试用奖励 $1 —— 只需在我们网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道和星星购买机器人中赠送 Telegram 星星! 新闻: ➡ Telegram 频道:https://t.me/accsforyou_shop ➡ WhatsApp 频道:https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器:https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram:https://t.me/socnet_support ➡ WhatsApp:https://wa.me/79051904467 ➡ Discord:socnet_support ➡ ✉ 邮箱:solomonbog@socnet.store
    • ANOTHER EPIC SERVER AND ANOTHER EPIC PROJECT! Thank You for using my support!   FAFURION UPDATER for upcoming server! Thank You for using my support! 
    • I will buy the code to the source for an overview of real states with char, p.atk/m.atk, pve damage / pve defense, pvp damage, pvp defense. I have l2jsunrise files
  • 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