PHP
Webbplats
PHP.net PHP.net Bugs PHP.net Wiki PHP my admin.netFörkortningar
- PHP - PHP: Hypertext (Pre)Process
- ERD - Entity Relationship Diagram
- PMA - PHP my admin
- PDO - PHP Data Objects
- UDF - User Defined Function
- GD - Graphics Draw
- SPL - Standard PHP Library
- PSR2
- PMA - Php my admin
- EOF - End Of File
- EOL - End Of Line
- APC - Alternative PHP Cache
- PECL - PHP Extension Community Library
- PEAR -
- CWD - current working directory
- NTS - Non-Thread Safe
- TS - Thread Safe
- CGI - Common Gateway Interface
- CS - CodeSniffer
- PHPCS - PHP CodeSniffer
Filändelser
- .php
Kända personer
- Rasmus Lerdorf
System
Editorer
Visa moduler
php -m
Visa alla moduler
- bcmath
- bz2
- calendar
- Core
- ctype
- curl
- date
- dba
- dom
- exif
- FFI
- fileinfo
- filter
- ftp
- gd
- gettext
- gmp
- hash
- iconv
- intl
- json
- ldap
- libxml
- mbstring
- mysqli
- mysqlnd
- odbc
- openssl
- pcntl
- pcre
- PDO
- pdo_dblib
- pdo_mysql
- PDO_ODBC
- pdo_pgsql
- pdo_sqlite
- pgsql
- Phar
- posix
- pspell
- readline
- Reflection
- session
- shmop
- SimpleXML
- soap
- sockets
- sodium
- SPL
- sqlite3
- standard
- sysvmsg
- sysvsem
- sysvshm
- tidy
- tokenizer
- xml
- xmlreader
- xmlwriter
- xsl
- Zend OPcache
- zip
- zlib
- Zend OPcache
Composer
Visa alla kommandon
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.4.3 2022-10-14 16:56:41 Usage: command [options] [arguments] Options: -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. --no-scripts Skips the execution of all scripts defined in composer.json file. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. --no-cache Prevent use of the cache -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: about Shows a short information about Composer archive Creates an archive of this composer package audit Checks for security vulnerability advisories for installed packages browse [home] Opens the package's repository URL or homepage in your browser bump Increases the lower limit of your composer.json requirements to the currently installed versions check-platform-reqs Check that platform requirements are satisfied clear-cache [clearcache|cc] Clears composer's internal package cache completion Dump the shell completion script config Sets config options create-project Creates new project from a package into given directory depends [why] Shows which packages cause the given package to be installed diagnose Diagnoses the system to identify common errors dump-autoload [dumpautoload] Dumps the autoloader exec Executes a vendored binary/script fund Discover how to help fund the maintenance of your dependencies global Allows running commands in the global composer dir ($COMPOSER_HOME) help Display help for a command init Creates a basic composer.json file in current directory install [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json licenses Shows information about licenses of dependencies list List commands outdated Shows a list of installed packages that have updates available, including their latest version prohibits [why-not] Shows which packages prevent the given package from being installed reinstall Uninstalls and reinstalls the given package names remove Removes a package from the require or require-dev require [r] Adds required packages to your composer.json and installs them run-script [run] Runs the scripts defined in composer.json search Searches for packages self-update [selfupdate] Updates composer.phar to the latest version show [info] Shows information about packages status Shows a list of locally modified packages suggests Shows package suggestions update [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file validate Validates a composer.json and composer.lockRamverk
- CakePHP
- Codeigniter
- Composer
- Kohana
- Laravel
- PHP DI
- Slim framework
- Symfony
- Get composer
- Get Symphony
- Twig
- Silverstripe
- Zend
CMS
Pakethanterare
composer
Funktion för att skriva ut version av PHP
phpversion()
Version av PHP
php --v
php --version
Vilken PHP?
which php
Kör fil med argument i UNIX
php -f file.php name
Sökväg
/usr/bin/php
PHP 7: 10 Things You Need to Know
- The Name’s PHP 7 (Not 6)
- The Brand Spanking New Zend Engine
- Twice The Speed
- Facilitates Error Handling
- 64-Bit Windows Systems Support
- New Spaceship and Null Coalescing Operators
- Enables Accurate Type Declarations
- Adds Anonymous Classes
- Facilitates Imports From the Same Namespace
- Cleans Up The Room
Citat
PHP is a popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.
Version
php -v
Plats
which php
Kommentarer
// En kommentar
# En kommentar
/* En kommentar */
@DATABASE@-%F-%T
The phpMyAdmin export process allows you to export into these formats
- SQL
- CVS
- CodeGen
- CVS for Microsoft Excel
- Microsoft Word 2000
- JSON
- LaTeX
- MediaWiki Table
- OpenDocument Spreadsheet
- OpenDocument Text
- PHP Array
- Texy! Text
- YAML
Cache
Test
Dirigera till URL
header('Location: /');
/Applications/MAMP/bin/php/php5.6.2/bin/php
Visa version av PHP med UNIX
php -v
Visa information om PHP med UNIX
php -i
Kör PHP-kod med UNIX
php -r ‘phpinfo();’
Kör en PHP-fil med UNIX
php -f filename.php
PhpMyAdmin
phpmyadmin > /usr/share/phpmyadmin/
/etc/php5(your php version)/apache2/php.ini
/usr/share/doc/phpmyadmin
Tid och datum
Visa tabell
format character |
Description | Example returned values |
---|---|---|
Day | --- | --- |
d | Day of the month, 2 digits with leading zeros | 01 to 31 |
D | A textual representation of a day, three letters | Mon through Sun |
j | Day of the month without leading zeros | 1 to 31 |
l (lowercase 'L') | A full textual representation of the day of the week | Sunday through Saturday |
N | ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) | 1 (for Monday) through 7 (for Sunday) |
S | English ordinal suffix for the day of the month, 2 characters | st, nd, rd or th. Works well with j |
w | Numeric representation of the day of the week | 0 (for Sunday) through 6 (for Saturday) |
z | The day of the year (starting from 0) | 0 through 365 |
Week | --- | --- |
W | ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) | Example: 42 (the 42nd week in the year) |
Month | --- | --- |
F | A full textual representation of a month, such as January or March | January through December |
m | Numeric representation of a month, with leading zeros | 01 through 12 |
M | A short textual representation of a month, three letters | Jan through Dec |
n | Numeric representation of a month, without leading zeros | 1 through 12 |
t | Number of days in the given month | 28 through 31 |
Year | --- | --- |
L | Whether it's a leap year | 1 if it is a leap year, 0 otherwise. |
o | ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) | Examples: 1999 or 2003 |
Y | A full numeric representation of a year, 4 digits | Examples: 1999 or 2003 |
y | A two digit representation of a year | Examples: 99 or 03 |
Time | --- | --- |
a | Lowercase Ante meridiem and Post meridiem | am or pm |
A | Uppercase Ante meridiem and Post meridiem | AM or PM |
B | Swatch Internet time | 000 through 999 |
g | 12-hour format of an hour without leading zeros | 1 through 12 |
G | 24-hour format of an hour without leading zeros | 0 through 23 |
h | 12-hour format of an hour with leading zeros | 01 through 12 |
H | 24-hour format of an hour with leading zeros | 00 through 23 |
i | Minutes with leading zeros | 00 to 59 |
s | Seconds, with leading zeros | 00 through 59 |
u | Microseconds (added in PHP 5.2.2). Note that date() will always generate 000000 since it takes an integer parameter, whereas DateTime::format() does support microseconds. | Example: 654321 |
Timezone | --- | --- |
e | Timezone identifier (added in PHP 5.1.0) | Examples: UTC, GMT, Atlantic/Azores |
I (capital i) | Whether or not the date is in daylight saving time | 1 if Daylight Saving Time, 0 otherwise. |
O | Difference to Greenwich time (GMT) in hours | Example: +0200 |
P | Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) | Example: +02:00 |
T | Timezone abbreviation | Examples: EST, MDT ... |
Z | Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. | -43200 through 50400 |
Full Date/Time | --- | --- |
c | ISO 8601 date (added in PHP 5) | 2004-02-12T15:19:21+00:00 |
r | » RFC 2822 formatted date | Example: Thu, 21 Dec 2000 16:01:07 +0200 |
U | Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | See also time() |
Sätt tidszon med PHP
date_default_timezone_set('Europa/Stockholm')
Visa felmeddelanden med PHP
error_reporting(E_ALL);
ini_set('display_errors', 1);
Loggar med felmeddelanden
tail -f /Applications/MAMP/logs/apache_error.log
tail -f /Applications/MAMP/logs/mysql_error_log.err
tail -f /Applications/MAMP/logs/php_error.log
PHP regular expression for replacement
$str = 'Lorem ipsum dolor';
$newstr = preg_replace('/lorem (.*?) ipsum/', '$1', $str);
stdClass is PHP's generic empty class
Citat
The file should be a PNG-8 format file, not PNG-24. There’s a bug in the current version of GD, which doesn’t support PNG-24 correctly
Typer variabler
Global
Static
Globala variabler med array (superglobals)
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
Variabel för $_SERVER
Visa alla variabler
- [HTTP_HOST]
- [HTTP_USER_AGENT]
- [HTTP_ACCEPT]
- [HTTP_ACCEPT_LANGUAGE]
- [HTTP_ACCEPT_ENCODING]
- [HTTP_ACCEPT_CHARSET]
- [HTTP_KEEP_ALIVE]
- [HTTP_CONNECTION]
- [HTTP_REFERER]
- [HTTP_COOKIE]
- [PATH]
- [SystemRoot]
- [COMSPEC]
- [PATHEXT]
- [WINDIR]
- [SERVER_SIGNATURE]
- [SERVER_SOFTWARE]
- [SERVER_NAME]
- [SERVER_ADDR]
- [SERVER_PORT]
- [REMOTE_ADDR]
- [DOCUMENT_ROOT]
- [SERVER_ADMIN]
- [SCRIPT_FILENAME]
- [REMOTE_PORT]
- [GATEWAY_INTERFACE]
- [SERVER_PROTOCOL]
- [REQUEST_METHOD]
- [QUERY_STRING]
- [REQUEST_URI]
- [SCRIPT_NAME]
- [PHP_SELF]
- [REQUEST_TIME]
Cookie
PHPSESSID
Sessioner
Starta en session
session_start()
Id för en session
session_id()
PHP-server
php -S "[::]:8000"
php -S "[::1]:8000"
Länkar
Externa länkar
- http://php.net/manual/en/language.oop5.php
- http://php.net/manual/en/language.oop5.basic.php
- http://php.net/manual/en/language.oop5.visibility.php
- http://php.net/manual/en/language.oop5.constants.php
- http://php.net/manual/en/language.namespaces.php
Variabel i PHP
$_SERVER['PHP_SELF']