top of page
Search

Php 検索 機能

  • Writer: Rolf Reeves
    Rolf Reeves
  • Sep 22, 2023
  • 10 min read

What is PHP? The PHP Programming Language Meaning Explained

PHP is an open-source server-side scripting language that many devs use for web development. It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).

In this article, I will help you explore the world of PHP so you can learn how it works and its basic features. By the end, you will be able to write your first Hello World program in PHP.

What Does PHP Mean?

The abbreviation PHP initially stood for Personal Homepage. But now it is a recursive acronym for Hypertext Preprocessor. (It's recursive in the sense that the first word itself is an abbreviation, so the full meaning doesn't follow the abbreviation.)

The first version of PHP was launched 26 years ago. Now it's on version 8, released in November 2020, but version 7 remains the most widely used.

PHP runs on the Zend engine, which is the most popular implementation. There are some other implementations as well, like parrot, HPVM (Hip Hop Virtual Machine), and Hip Hop, created by Facebook.

PHP is mostly used for making web servers. It runs on the browser and is also capable of running in the command line. So, if you don't feel like showing your code output in the browser, you can show it in the terminal.

Advantages of PHP

PHP has some advantages that have made it so popular, and it's been the go-to language for web servers for more than 15 years now. Here are some of PHP's benefits:

  1. Cross-Platform: PHP is platform-independent. You don't have to have a particular OS to use it because it runs on every platform, whether it's Mac, Windows, or Linux.

  2. Open Source: PHP is open source. The original code is made available to everyone who wants to build upon it. This is one of the reasons why one of its frameworks, Laravel, is so popular.

  3. Easy to learn: PHP is not hard to learn for absolute beginners. You can pick it up pretty if you already have programming knowledge.

  4. PHP syncs with all Databases: You can easily connect PHP to all Databases, relational and non-relational. So it can connect in no time to MySQL, Postgress, MongoDB, or any other database.

  5. Supportive Community: PHP has a very supportive online community. The official documentation provides guides on how to use the features and you can easily get your problem fixed while stuck.

Who Uses PHP

A number of established companies and tech giants use PHP to run their servers and make a lot of incredible things.

  1. Facebook: Facebook uses PHP to power its site. In turn, the company contributed to the community by creating an implementation known as Hip Hop for PHP.

  2. Wikipedia: one of the world's largest sources of information on any topic, Wikipedia is built in PHP.

  3. Content Management Systems (CMSs): the world's most popular content management system, WordPress, is built in PHP. Other content management systems such as Drupal, Joomla, and Magento are also built in PHP. Shopify runs on PHP too.

  4. Web Hosting Platforms: a lot of Web Hosting Platforms such as BlueHost, Site ground, and Whogohost run their hosting servers using PHP.

Is PHP Dying?

Nowadays, there's an intense debate on whether PHP is on the decline or not. This is because of the advent and increasing popularity of other languages suited for the server-side such as JavaScript (Node JS), Python, Golang, and others.

This has actually led to a lot of funny memes targeting PHP

But is PHP really dying? The answer is no. Despite some people bashing on it and the claims of decline, PHP is still used to run the servers of almost 80% of all websites today. So, if you visit 10 websites a day, there's a chance that 8 of them use PHP.

In terms of job availability, PHP ranks better than a lot of other programming languages on the job platform Indeed. A lot of PHP developers make a good living making WordPress themes and plugins every year – the average PHP developer in the US makes $86,000 per year.

How to Write Your First Hello World Program in PHP

Now that you have learned about PHP and its advantages, it's time to write your first Hello World program in it!

First of all, you must have PHP installed on your local machine. You can get that done by installing an XAMP (Cross-Platform, Apache, MySQL, and PHP) or WAMP (Windows, Apache, MySQL, and PHP) server.

XAMP works on all operating systems and WAMP works only in Windows. I will be using WAMP.

Open up the WAMP or XAMP server and make sure all services are running. If you are using WAMP, the WAMP logo should show on your taskbar with the color green.

Open up your C drive and look for the installation directory of your WAMP server. In my case, it is wamp64 .

Open the installation directory, and then the www folder.

Create a folder right there and name it whatever you want, then open up the folder with your code editor.

Create an index.php file and paste in the following code:

You can also put your 'Hello World' text in a variable, then use the echo system to display it in the browser.

In PHP, you can declare a variable with the dollar sign ($). Your statements, apart from the last one, must also be terminated by a semi-colon.

To run your code in the browser, open up the browser and write this in the address bar localhost/the-folder-of-your-php-file/php-file.php , then hit enter.

Make sure your WAMP or XAMP server is running, otherwise it won't work.

You can see that the code successfully ran in the browser, because I got the file path right.

Another beautiful thing about PHP is that you can embed it in HTML. You can do it like this:

 PHP Code 

This is the result of a PHP Code embedded in HTML '; echo $campers ?>

Conclusion

PHP remains a relevant and widely-used language in web development. Despite the mockery and debate on whether it's still valuable, PHP developers keep earning good livings from working with the language. So, PHP doesn't seem to be going anywhere anytime soon.

Thank you for reading, and keep coding.

PHP | Introduction

The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a server-side scripting language designed specifically for web development. It is open-source which means it is free to download and use. It is very simple to learn and use. The files have the extension '.php'.

Rasmus Lerdorf inspired the first version of PHP and participated in the later versions. It is an interpreted language and it does not require a compiler.

  1. PHP code is executed in the server.

  2. It can be integrated with many databases such as Oracle, Microsoft SQL Server, MySQL, PostgreSQL, Sybase, and Informix.

  3. It is powerful to hold a content management system like WordPress and can be used to control user access.

  4. It supports main protocols like HTTP Basic, HTTP Digest, IMAP, FTP, and others.

  5. Websites like www.facebook.com and www.yahoo.com are also built on PHP.

  6. One of the main reasons behind this is that PHP can be easily embedded in HTML files and HTML codes can also be written in a PHP file.

  7. The thing that differentiates PHP from the client-side language like HTML is, that PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. PHP codes are first executed on the server and then the result is returned to the browser.

  8. The only information that the client or browser knows is the result returned after executing the PHP script on the server and not the actual PHP codes present in the PHP file. Also, PHP files can support other client-side scripting languages like CSS and JavaScript.

  9. Simple and fast

  10. Efficient

  11. Secured

  12. Flexible

  13. Cross-platform, it works with major operating systems like Windows, Linux, and macOS.

  14. Open Source

  15. Powerful Library Support

  16. Database Connectivity

HTML

Hello, World! This is PHP code

Why should we use PHP?

PHP can actually do anything related to server-side scripting or more popularly known as the backend of a website. For example, PHP can receive data from forms, generate dynamic page content, can work with databases, create sessions, send and receive cookies, send emails, etc. There are also many hash functions available in PHP to encrypt users' data which makes PHP secure and reliable to be used as a server-side scripting language. So these are some of PHP's abilities that make it suitable to be used as a server-side scripting language. You will get to know more of these abilities in further tutorials. Even if the above abilities do not convince you of PHP, there are some more features of PHP. PHP can run on all major operating systems like Windows, Linux, Unix, Mac OS X, etc. Almost all of the major servers available today like Apache supports PHP. PHP allows using a wide range of databases. And the most important factor is that it is free to use and download and anyone can download PHP from its official source: www.php.net. Please refer to setting up the development environment and basic syntax of PHP in further articles.

  1. PHP 7 is faster than the previous versions.

  2. PHP 7 supports new operators.

  3. PHP 7 supports better Error Handling functionalities.

  4. PHP 7 supports stricter declarations for types in function parameters. References:

  5. https://en.wikipedia.org/wiki/PHP

  6. http://php.net/manual/en/introduction.php

Disadvantages of PHP:

  1. PHP is not secure as it is open source.

  2. Not good to create desktop applications.

  3. Not suitable for large Web Applications- Php code is hard to maintain since it is not very modular.

  4. Modification Problem – PHP does not allow the change in the core behavior of the web applications.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

PHPでの検索フォーム実装方法〜Webシステム開発に必要な知識を解説〜

「テキストフォーム」で入力した内容は「検索」ボタンでサーバーに送信され、指定したプログラムで処理されることになります。 プログラムは色々な言語で書かれることになりますが、 Webシステムを構築するのに最も適していると言われているのが「PHP」 です。 PHPとは正式名称を「PHP:Hypertext preprocessor」といい、htmlと組み合わせて記述することができるプログラム言語のため、多くのWebシステム開発に使われています。

「検索フォーム」を実装する場合は、htmlから受け取ったデータを「SQL文」に組み込み、「MySQL」と呼ばれるデータベースシステムに送信する処理を構築することになります。 また、データベースから返された結果をhtmlにわたす役目もありますので、 ユーザーとデータベースとの橋渡し的な存在 と言えるでしょう。

MySQLによるデータベース構築

MySQLとはオープンソースで提供されているデータベースシステム のことで、無料のレンタルサーバーでも利用できることが多く、大規模なWebシステムでの運用にも耐えられる頑丈な作りとなっているため、ほとんどのWebシステムで利用されているといっても過言ではありません。

「検索フォーム」を実装する場合は、プログラムからSQL文を受け取り、データベースにあるデータを検索したあと、プログラムにデータベースの抽出結果を返却する処理を行います。 ユーザーの要求を実際に実行していく部分 となりますので、Webシステムで一番重要な部分を担っていると言えるでしょう。 当然、データベースを理解していなければWebシステムを構築することはできませんので、データベースの基礎知識について、もう少し詳しくみていきましょう。

リレーショナルデータベース

MySQLに限らず、多くのデータベースは「 リレーショナル型 」と呼ばれる手法でデータを扱っています。 リレーショナルデータベースを簡単に説明すると、以下のような特徴があるデータベースです。

例えばショッピングサイトで販売する商品を「商品ID」「商品名」「価格」「カテゴリ」といった項目で管理している場合、リレーショナルデータベースでは、「商品」という表と「カテゴリ」という表といった具合に、 複数の表に分けてデータを管理 し、「カテゴリID」という キーで結合して表現 することになります。

このように、複数の表を使ってデータを管理することで、 データの整合性を確保 することができるようになります。

例えば、上表の場合、テレビとブルーレイレコーダーは「ビジュアル家電」という同じカテゴリで管理されなければなりませんが、ブルーレイレコーダーのカテゴリを「ビデオ家電」と誤登録してしまうと、同じカテゴリで管理できなくなってしまいます。 商品表にはカテゴリIDだけ登録し、カテゴリ表と照合しながら管理でき、 データベース上に存在しないデータの誤登録を防ぐという点 が、リレーショナルデータベースの大きな特徴と言ってよいでしょう。

ER図・状態遷移図

プログラム言語やデータベースを理解したところで早速Webシステム開発に着手してみましょう、と言いたいところですが、実際にWebシステムを構築していくには、それだけでは不十分である可能性があります。 特に大規模なデータベースシステムを構築したい場合、 データベースをER図というもので視覚的に表したり、システム上の画面遷移や状態遷移を明示したりするスキルが必要 となってきます。

スキル習得は一朝一夕にはいきませんので、ここでは、上述の例で構築したデータベースの場合を ER図 にしてみることにします。

この図を参考に、各々で 構築したいデータベースを想定しながらER図を作る 練習をしてみていただければと思います。

なお「検索フォーム」を構築する場合の 状態遷移図 は以下のようなものになります。 こちらも各々で 構築したいWebシステムを想定しながら状態遷移図を作る 練習をしていただければと思います。

ER図はともかく、画面遷移図や状態遷移図は 人によって様々な書き方がある ように思われます。

重要なのは画面や状態の遷移が分かりやすく書けているかどうかがポイントとなりますので、「どのように書けばよいか分からない」と言った方は、 堅苦しく考えず「どのように遷移するかが伝わればよい」といった程度の気楽な気持ち で書くとよいかもしれません。

PHPでの検索フォーム実装方法 実装内容

Webシステム構築のための基礎知識を把握したところで、早速、 「検索フォーム」を実装する方法 について考えていきましょう。

html・form要素

まずはhtml部分です。 「検索フォーム」を実装するには、何はともあれ「検索する文字」を入力する「テキストボックス」と、「入力した内容で検索を実行する」ための「検索ボタン」が必要です。 テキストボックス検索ボタン については以下のように記述して実装します。

 
 
 

Comments


About Xanphia

Xanphia is a blog dedicated to exploring life and sharing our experiences with our readers. Join our mailing list to stay up-to-date with our latest posts and adventures.

Join Our Mailing List

Thank You for Subscribing!

© 2021 Xanphia. Powered by Wix

  • Facebook
  • Instagram
  • Pinterest
  • Twitter
bottom of page