Skip to content
Search

PHP

lastmod 2025-09-03created 2014-01-0558 edits

PHP Tutorial

PHP Basic

  • PHP HOME
  • PHP Intro
  • PHP Install
  • PHP Syntax
  • PHP Variables
  • PHP Echo / Print
  • PHP Data Types
  • PHP String Functions
  • PHP Constants
  • PHP Operators
  • PHP If...Else...Elseif
  • PHP Switch
  • PHP While Loops
  • PHP For Loops
  • PHP Functions
  • PHP Arrays
  • PHP Sorting Arrays
  • PHP Superglobals

PHP Forms

  • PHP Form Handling
  • PHP Form Validation
  • PHP Form Required
  • PHP Form URL/E-mail
  • PHP Form Complete

PHP Advanced

  • PHP Arrays Multi
  • PHP Date
  • PHP Include
  • PHP File
  • PHP File Upload
  • PHP Cookies
  • PHP Sessions
  • PHP E-mail
  • PHP Secure E-mail
  • PHP Error
  • PHP Exception
  • PHP Filter

PHP Database

  • PHP MySQL Intro
  • PHP MySQL Connect
  • PHP CREATE DB/Table
  • PHP INSERT INTO
  • PHP SELECT
  • PHP WHERE
  • PHP ORDER BY
  • PHP UPDATE
  • PHP DELETE
  • PHP ODBC

PHP XML

  • XML Expat Parser
  • XML DOM
  • XML SimpleXML

PHP and AJAX

  • AJAX Intro
  • AJAX PHP
  • AJAX Database
  • AJAX XML
  • AJAX Live Search
  • AJAX RSS Reader
  • AJAX Poll

PHP Examples

  • PHP Examples
  • PHP Quiz
  • PHP Certificate

PHP Reference

  • PHP Array
  • PHP Calendar
  • PHP Date
  • PHP Directory
  • PHP Error
  • PHP Filesystem
  • PHP Filter
  • PHP FTP
  • PHP HTTP
  • PHP Libxml
  • PHP Mail
  • PHP Math
  • PHP Misc
  • PHP MySQLi
  • PHP SimpleXML
  • PHP String
  • PHP XML
  • PHP Zip
  • PHP Timezones

Categories

Libraries

  • php-crud-api - Add a REST API to a DB with a single file
  • slime - A small api framework with Slim v3 +Eloquent, to create easily Restful services

ETC

  • php-node - A handler that processes PHP HTTP requests inside Node.js

Functions

  • get_current_user(): Returns the name of the owner of the current PHP script.
  • var_dump($var): This function displays structured information about one or more expressions, including their type and value. Arrays and objects are explored recursively to show their structure.
  • is_writable($filename): Returns TRUE if the filename exists and is writable.
  • posix_getuid(): Return the numeric real user ID of the current process.
  • debug_print_backtrace(): prints a PHP backtrace.

How to instasll

  • See also: MediaWiki:Install#CentOS_7

Install PHP:

$ yum -y install php
## For developer:
$ yum -y install php-devel

MySQL module:

$ yum -y install php-mysql

Common PHP modules:

$ yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

Ubuntu

sudo apt-get install apache2 libapache2-mod-php5
## libapache2-mod-php5 provides the following PHP extensions: bcmath bz2 calendar Core ctype date dba dom ereg exif fileinfo filter ftp gettext hash iconv libxml mbstring mhash openssl pcre Phar posix Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter zip zlib.

Recommended Modules:

$ apt-get install php5-gd php5-json php5-mysql php5-curl
$ apt-get install php5-intl php5-mcrypt php5-imagick

Configuration

Notes on how to configure PHP.

How to find PHP configuration file information

You can get information such as PHP's INI file.

$ php --ini | grep "Loaded Configuration File:"

Setting the PHP file upload size limit

Edit the variables below in php.ini. 1

post_max_size = 100M
memory_limit = 100M
upload_max_filesize = 100M

Allowing PHP short tags

By default, PHP does not allow short tags such as <? ... ?>. Short tags are not recommended because they clash with XML expressions like the one below.

  • <code><?xml version="1.0" encoding="UTF-8"?>

    </code>

If you still want to use short tags, do the following.

short_open_tag = On

register_globals

With rester_globals set to ON, you do not need to check whether a variable is a get, post, or session variable. Depending on how it is used, this can cause security problems.

  • register_globals = on
    • Allowed: $_POST['u_id']
    • Allowed: $u_id
  • register_globals = off
    • Allowed: $_POST['u_id']
    • Not allowed: $u_id
    • Possible if handled with extrract().

How to install extension libraries

Pecl Intl
Installing/enabling PHP Pecl Intl extension on CentOs 5
yum install php-intl
PHP sqlite3
Not Installing Sqlite 3 on CentOS correctly
yum install php-pdo

Troubleshooting

Notes on solving problems that can occur while using PHP.

Fatal exception of type MWException Error

To print detailed error logs, add the Setting variable as below.

$wgShowExceptionDetails = true;

Not working phpinfo()

You can use the phpinfo() function as below.

<? phpinfo(); ?>

But if it does not print correctly, change it as below.

<?php phpinfo(); ?>

See also

Favorite site

PHP Framwork

PHP Security

PEAR and PECL

PHP Install

Debugging

Article

References


  1. Located at /etc/php.ini or /etc/php5/apache2/php.ini, etc. ↩

  2. Linux_php_security.pdf ↩

  3. http://suhosin.org/stories/index.html ↩

author Zer0 sitemap