Предопределенные константы
Перечисленные ниже константы определены данным расширением и могут быть доступны только в том случае, если PHP был собран с поддержкой этого расширения или же в том случае, если данное расширение подгружается во время выполнения.
RADIUS_ACCESS_REQUEST () Authentication Request RADIUS_ACCESS_ACCEPT () Access accepted RADIUS_ACCESS_REJECT () Access rejected RADIUS_ACCOUNTING_REQUEST () Accounting request RADIUS_ACCOUNTING_RESPONSE () Accounting response RADIUS_ACCESS_CHALLENGE () Accsess challenge RADIUS_USER_NAME (string) Username RADIUS_USER_PASSWORD (string) Password RADIUS_CHAP_PASSWORD (string) Chap Password: chappass = md5(ident + plaintextpass + challenge) RADIUS_NAS_IP_ADDRESS (string) NAS IP-Adress RADIUS_NAS_PORT (int) NAS Port RADIUS_SERVICE_TYPE (int)
Type of Service, one of:
Framed Protocol, one of:
RADIUS_FRAMED_IP_ADDRESS (string) IP-Address RADIUS_FRAMED_IP_NETMASK (string) Netmask RADIUS_FRAMED_ROUTING (int) Routing RADIUS_FILTER_ID (string) Filter ID RADIUS_FRAMED_MTU (int) MTU RADIUS_FRAMED_COMPRESSION (int)
Compression, one of:
RADIUS_LOGIN_IP_HOST (string) Login IP Host RADIUS_LOGIN_SERVICE (int) Login Service RADIUS_LOGIN_TCP_PORT (int) Login TCP Port RADIUS_REPLY_MESSAGE (string) Reply Message RADIUS_CALLBACK_NUMBER (string) Callback Number RADIUS_CALLBACK_ID (string) Callback ID RADIUS_FRAMED_ROUTE (string) Framed Route RADIUS_FRAMED_IPX_NETWORK (string) Framed IPX Network RADIUS_STATE (string) State RADIUS_CLASS (int) Class RADIUS_VENDOR_SPECIFIC (int) Vendor specific attribute RADIUS_SESSION_TIMEOUT (int) Session timeout RADIUS_IDLE_TIMEOUT (int) Idle timeout RADIUS_TERMINATION_ACTION (int) Termination action RADIUS_CALLED_STATION_ID (int) Called Station Id RADIUS_CALLING_STATION_ID (string) Calling Station Id RADIUS_NAS_IDENTIFIER (int) NAS ID RADIUS_PROXY_STATE (int) Proxy State RADIUS_LOGIN_LAT_SERVICE (int) Login LAT Service RADIUS_LOGIN_LAT_NODE (int) Login LAT Node RADIUS_LOGIN_LAT_GROUP (int) Login LAT Group RADIUS_FRAMED_APPLETALK_LINK (int) Framed Appletalk Link RADIUS_FRAMED_APPLETALK_NETWORK (int) Framed Appletalk Network RADIUS_FRAMED_APPLETALK_ZONE (int) Framed Appletalk Zone RADIUS_CHAP_CHALLENGE (string) Challenge RADIUS_NAS_PORT_TYPE (int)
NAS port type, one of:
RADIUS_PORT_LIMIT (int) Port Limit RADIUS_LOGIN_LAT_PORT (int) Login LAT Port RADIUS_CONNECT_INFO (string) Connect info RADIUS_ACCT_STATUS_TYPE (int)
Accounting status type, one of:
RADIUS_ACCT_DELAY_TIME (int) Accounting delay time RADIUS_ACCT_INPUT_OCTETS (int) Accounting input bytes RADIUS_ACCT_OUTPUT_OCTETS (int) Accounting output bytes RADIUS_ACCT_SESSION_ID (int) Accounting session ID RADIUS_ACCT_AUTHENTIC (int)
Accounting authentic, one of:
RADIUS_ACCT_SESSION_TIME (int) Accounting session time RADIUS_ACCT_INPUT_PACKETS (int) Accounting input packets RADIUS_ACCT_OUTPUT_PACKETS (int) Accounting output packets RADIUS_ACCT_TERMINATE_CAUSE (int)
Accounting terminate cause, one of:
- RADIUS_TERM_USER_REQUEST
- RADIUS_TERM_LOST_CARRIER
- RADIUS_TERM_LOST_SERVICE
- RADIUS_TERM_ >RADIUS_TERM_SESSION_TIMEOUT
- RADIUS_TERM_ADMIN_RESET
- RADIUS_TERM_ADMIN_REBOOT
- RADIUS_TERM_PORT_ERROR
- RADIUS_TERM_NAS_ERROR
- RADIUS_TERM_NAS_REQUEST
- RADIUS_TERM_NAS_REBOOT
- RADIUS_TERM_PORT_UNNEEDED
- RADIUS_TERM_PORT_PREEMPTED
- RADIUS_TERM_PORT_SUSPENDED
- RADIUS_TERM_SERVICE_UNAVAILABLE
- RADIUS_TERM_CALLBACK
- RADIUS_TERM_USER_ERROR
- RADIUS_TERM_HOST_REQUEST
RADIUS_ACCT_MULTI_SESSION_ID (string) Accounting multi session ID RADIUS_ACCT_LINK_COUNT (int) Accounting link count RADIUS_VENDOR_MICROSOFT (int)
Microsoft specific vendor attributes (� RFC 2548), one of:
- RADIUS_MICROSOFT_MS_CHAP_RESPONSE
- RADIUS_MICROSOFT_MS_CHAP_ERROR
- RADIUS_MICROSOFT_MS_CHAP_PW_1
- RADIUS_MICROSOFT_MS_CHAP_PW_2
- RADIUS_MICROSOFT_MS_CHAP_LM_ENC_PW
- RADIUS_MICROSOFT_MS_CHAP_NT_ENC_PW
- RADIUS_MICROSOFT_MS_MPPE_ENCRYPTION_POLICY
- RADIUS_MICROSOFT_MS_MPPE_ENCRYPTION_TYPES
- RADIUS_MICROSOFT_MS_RAS_VENDOR
- RADIUS_MICROSOFT_MS_CHAP_DOMAIN
- RADIUS_MICROSOFT_MS_CHAP_CHALLENGE
- RADIUS_MICROSOFT_MS_CHAP_MPPE_KEYS
- RADIUS_MICROSOFT_MS_BAP_USAGE
- RADIUS_MICROSOFT_MS_LINK_UTILIZATION_THRESHOLD
- RADIUS_MICROSOFT_MS_LINK_DROP_TIME_LIMIT
- RADIUS_MICROSOFT_MS_MPPE_SEND_KEY
- RADIUS_MICROSOFT_MS_MPPE_RECV_KEY
- RADIUS_MICROSOFT_MS_RAS_VERSION
- RADIUS_MICROSOFT_MS_OLD_ARAP_PASSWORD
- RADIUS_MICROSOFT_MS_NEW_ARAP_PASSWORD
- RADIUS_MICROSOFT_MS_ARAP_PASSWORD_CHANGE_REASON
- RADIUS_MICROSOFT_MS_FILTER
- RADIUS_MICROSOFT_MS_ACCT_AUTH_TYPE
- RADIUS_MICROSOFT_MS_ACCT_EAP_TYPE
- RADIUS_MICROSOFT_MS_CHAP2_RESPONSE
- RADIUS_MICROSOFT_MS_CHAP2_SUCCESS
- RADIUS_MICROSOFT_MS_CHAP2_PW
- RADIUS_MICROSOFT_MS_PRIMARY_DNS_SERVER
- RADIUS_MICROSOFT_MS_SECONDARY_DNS_SERVER
- RADIUS_MICROSOFT_MS_PRIMARY_NBNS_SERVER
- RADIUS_MICROSOFT_MS_SECONDARY_NBNS_SERVER
- RADIUS_MICROSOFT_MS_ARAP_CHALLENGE
��������� � PHP
������. ������� ����� �������� � ���������� � PHP. �������� ��� ��������� ��������, ����� ���� ����� ����������� � ������ .
��� ����� ��������� � ��������� PHP?
��������� � ��� �� ���� ���������� � ������� ������ �������������� ��������. �.� ����� �������� �� �������� �� ������ �� ������� ��� ������ �� ���� ���������� �������. ��� ��� ������� ������� � ������� �������� � � �������� ��������� �������� �������� � ��� ����������.
� PHP ���������� 2 ������������� ��������:
- ������� (�������� �������������)
- ���������������� (�������� ���������������)
������� ���������
����� ��� �������� ������ ������������ ��� ������� ��� ��������� ����� � ��������� ������������� � �������� ��������� ����.
��������� �������� ������� ���������:
�������� ��������� ���������� � ������� ���������� ����������� define (‘��� ���������’,’�������� ���������’).
��� �������� ��������� ��������� ������ � ����������� ������ ������ ���� ��� �������� � ���������� �������� ���� ���, � ����� �� ����� ���� ��������:
��� ���� ����� ��������� ������������� ��������� � ����� ������������� ������� defined (�CONST_NAME�).
���������������� ���������
���������������� ��������� ���������� �� ������� �������� ��������. ��� ��������������� ����� ��������������� � ������ ���� �������� � ��������� ���������� ���������. ��� �� ��� �� ������������� � ��������, __CLASS__ ��� __class__ ����� ��������� ��������� ���������������.
��� ����� ����� ������������ ���������������� ���������:
- __FILE__ � ������ ��� ������������ �� ������ ������ �������.
- __FUNCTUIN__ � ��� ������� �������.
- __CLASS__ � ��� �������� ������.
- PHP_VERSION � �������� ������ �������������� PHP.
- TRUE, FALSE, NULL � �������� � ���� �������� ��������������� ������ ��������.
��� ������� ������ ����� �������� ��������� �� ������������� ����� �� ��� � __FUNCTION__ :
��� ����� ������ �� ������� ��������� __function__ ������� ��� ������� � ������� ��� ���� ������������� ������� � abc ().
� ��, ��������� ���������� ������� ��� ������� ���������� �������� unset (), ��� ���������� �� ������ � �� ����� ���������� ���������.
�� ���� ���, ����� �������� �������� � �������� ����������. �� �������.
dmkweb.ru ����� �� ������� ��������.
����������� �� ���������� �����
��������������� ��������� session
���������, ��� � ���������� ������ ������������ ��������, ������ � ������� �� ���������� �������� �������� ����� ���� ����������� ������ ���� ���, � ����� �� ��� �� ����� ��� ��������. ��������, ��������� �������� ���������:
��� ����������� ��������� ������������ �������� define , ������� ����� ��������� �����: define(string $name, string $value, bool $case_sen=false) . �������� $name �������� �������� ���������, � �������� $value — �� ��������. ������ �������������� �������� ��������� ���������� �������� true ��� false . ���� �������� ����� false, �� ��� ������������� ��������� ����� ����������� �� �������, ���� true — ������� �� �����������. � ����� ������ ������ �������� �� �����������, ������� �� �� ��������� ����� false.
����� ����������� ��������� �� ����� �� ������������ �����, ��� � ������� ����������. ������������ ���������� — �� �� ������ �������� �� ��������. ������ ������� �� ���������� — �� ���� ������������ ���� $ . �� ���� ��������� NUMBER=33; �������� �� �����.
���������������� ���������
����� ����������� ������������� �������� � PHP ������� ��� ��������� ���������� ��������:
__FILE__ : ������ ������ ���� � ��� �������� �����
__LINE__ : ������ ������� ����� ������, ������� ������������ �������������
__DIR__ : ������ ������� �������� �����
__FUNCTION__ : �������� �������������� �������
__CLASS__ : �������� �������� ������
__METHOD__ : �������� ��������������� ������
__NAMESPACE__ : �������� �������� ������������ ����
��������, ������� ������� ����������� ������ � �������� �����:
�������� ������������� ���������
����� ���������, ���������� �� ���������, �� ����� ������������ ������� bool defined(string $name) . ���� ��������� $name ����������, �� ������� ����� ���������� �������� true
XCIII. Session handling functions
Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.
If you are familiar with the session management of PHPLIB, you will notice that some concepts are similar to PHP’s session support.
A visitor accessing your web site is assigned an unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL.
The session support allows you to register arbitrary numbers of variables to be preserved across requests. When a visitor accesses your site, PHP will check automatically (if session.auto_start is set to 1) or on your request (explicitly through session_start() or implicitly through session_register() ) whether a specific session id has been sent with the request. If this is the case, the prior saved environment is recreated.
All registered variables are serialized after the request finishes. Registered variables which are undefined are marked as being not defined. On subsequent accesses, these are not defined by the session module unless the user defines them later.
���������: Session handling was added in PHP 4.0.
The session module cannot guarantee that the information you store in a session is only viewed by the user who created the session. You need to take additional measures to actively protect the integrity of the session, depending on the value associated with it.
Assess the importance of the data carried by your sessions and deploy addditional protections — this usually comes at a price, reduced convenience for the user. For example, if you want to protect users from simple social engineering tactics, you need to enable session.use_only_cookies. In that case, cookies must be enabled unconditionally on the user side, or sessions will not work.
There are several ways to leak an existing session id to third parties. A leaked session id enables the third party to access all resources which are associated with a specific id. First, URLs carrying session ids. If you link to an external site, the URL including the session id might be stored in the external site’s referrer logs. Second, a more active attacker might listen to your network traffic. If it is not encrypted, session ids will flow in plain text over the network. The solution here is to implement SSL on your server and make it mandatory for users.
��� ������� ������ ��������.
Session support is enabled in PHP by default. If you would not like to build your PHP with session support, you should specify the —disable-session option to configure. To use shared memory allocation (mm) for session storage configure PHP —with-mm[=DIR] .
������ PHP ��� Windows-����������� �������� ����� ���������� ��������� ������� ����������. ��� ��������, ��� ��� ������������� ������ ������� �� ��������� �������� ������� �������������� ����������.
��������� ���� ������� ��������� � ����������� �� ��������� � php.ini .
������� 1. Session configuration options
Name | Default | Changeable |
---|---|---|
session.save_path | «/tmp» | PHP_INI_ALL |
session.name | «PHPSESSID» | PHP_INI_ALL |
session.save_handler | «files» | PHP_INI_ALL |
session.auto_start | «0» | PHP_INI_ALL |
session.gc_probability | «1» | PHP_INI_ALL |
session.gc_maxlifetime | «1440» | PHP_INI_ALL |
session.serialize_handler | «php» | PHP_INI_ALL |
session.cookie_lifetime | «0» | PHP_INI_ALL |
session.cookie_path | «/» | PHP_INI_ALL |
session.cookie_domain | «» | PHP_INI_ALL |
session.cookie_secure | «» | PHP_INI_ALL |
session.use_cookies | «1» | PHP_INI_ALL |
session.use_only_cookies | «0» | PHP_INI_ALL |
session.referer_check | «» | PHP_INI_ALL |
session.entropy_file | «» | PHP_INI_ALL |
session.entropy_length | «0» | PHP_INI_ALL |
session.cache_limiter | «nocache» | PHP_INI_ALL |
session.cache_expire | «180» | PHP_INI_ALL |
session.use_trans_sid | «0» | PHP_INI_SYSTEM|PHP_INI_PERDIR |
url_rewriter.tags | «a=href,area=href,frame=src,input=src,form=fakeentry» | PHP_INI_ALL |
The session management system supports a number of configuration options which you can place in your php.ini file. We will give a short overview.
session.save_handler defines the name of the handler which is used for storing and retrieving data associated with a session. Defaults to files . See also session_set_save_handler() .
session.save_path defines the argument which is passed to the save handler. If you choose the default files handler, this is the path where the files are created. Defaults to /tmp . If session.save_path ‘s path depth is more than 2, garbage collection will not be performed. See also session_save_path() .
�������� | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
��������������� | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
��� ���������� | ��� | �������� |
---|---|---|
APPLICATION | � | ���������� ������ ������ CMain, ������������ ��� ���������� ����������� ����� ����������� �������� (����� ���������, ������������� �������, ���� � �.�.). |
USER | � | ���������� ������ ������ CUser, ������ � ���� ������ ����������� �������� ������������, ������������ ��� ����������� ����������� �������� ������������. |
DB | � | ���������� ������ ������ CDataBase, ������������ ��� ������ � ����� ������. |
DBType | � | ��� ����: «mysql», «mssql» ��� «oracle».
������: |
DBHost | � | ��� ��������� ����� ���� ������:
������: |
DBName | � | ��� ��������� ����� ���� ������:
������ ��� MySQL:������ ��� Oracle: |
DBLogin | � | ����� ������������ ��� ������� � ���� ������.
������: |
DBPassword | � | ������ ������������ ��� ������� � ���� ������.
������: |
DBDebug | � � |
���� ������ ���������� ����� ����� «true», �� � ������ ������ ��� �������� ���������� � ����� ��� � ����� SQL �������, ��������� �� ������ � ������ ����� ���� ������ ����� ������������ � ��������. � ��������� ������ — ������ ����� ������ ����� ������� ������ �������������� �����.
������: |
DBDebugToFile | � � |
���� ������ ���������� ����� ����� «true», �� ��� SQL ������� � ���� ������ � ����� �� ���������� ����� ������������ � ���-���� /mysql_debug.sql (��� /oracle_debug.sql). ������ ����������� ������������ ��� ������� ��� ��������� ������ � �������� ���������� SQL �������� � ���� ������.
������� ��������� ���� ����� �������� ��������� ������ �����, ������� ������������ ���� ����� ��������������. ������: |
clear_cache | � | ���� �������� ������ ���������� — «Y», �� ��� ��������� ����������� �� ������� ��������.
������: |
clear_cache_session | � | ���� �������� ������ ���������� — «Y», �� ��� ��������� ����������� � ������ ������. ��� ��������� ����������� — ���������� ���� ��� ��������� ���� ���������� �������� «N».
������: |
compress | � | ���� �������� ������ ���������� — «Y», �� ����� �������� � ������ ������ ����� �������� ����� ������������ ���������� �� ������ ������ �������� ������� «����������»: ������ �������� �� ������, ������ �������� ����� ������, ���������� ������. ��� ���������� ������ ������ ���������� — ���������� ���� ��� ��������� ���� ���������� �������� «N».
������: |
show_page_exec_time | � | ���� �������� ������ ���������� — «Y», �� ����� �������� ����� ���������� ����� ���������� ������ �������� �� �������. ������ ���������� ����� ���������� � ������ ������. ��� ���������� �� ������ — ���������� ���� ��� ��������� ���� ���������� �������� «N».
������ ���������� ��������� �������� ����������� ���������� � �������� ������ �����. ������: |
show_include_exec_time | � | ���� �������� ������ ���������� — «Y», �� �� �������� ����� �������� ����� ���������� ���� ������� CMain::IncludeFile, ������������ ��� ���������� ��� � ������� �����. ������ ���������� ����� ���������� � ������ ������. ��� ���������� �� ������ — ���������� ���� ��� ��������� ���� ���������� �������� «N».
������: |
show_lang_files | � | ���� �������� ������ ���������� — «Y», �� ����� �������� ����� ���������� ������ ������������ �� ������ �������� �������� ������ � ������������ ������ �� ���. ������ ���������� ����� ���������� � ������ ������. ��� ���������� �� ������ — ���������� ���� ��� ��������� ���� ���������� �������� «N».
������ ���������� ��������� ������ ����� �� ��� ���� �������� �����. ������: |
no_keep_statistic_KEY | � | ���� �������� ������ ���������� — «Y», �� ��� �������� ��������� ���� ���������� � ������ ������. ��� ��������� ����� ���������� — ���������� ���� ��� ��������� ���� ���������� �������� «N». ��� ������� ������ ���������� ���������� ��� ���������� ����� ���������� � ������ ������ �� ���� ��������������.
KEY — ������������ ���� �������� � ����� /bitrix/license_key.php ������: |
no_agent_statistic_KEY | � | ���� �������� ������ ���������� — «Y», �� ��� �������� ��������� ��������� ������� ���������� � ������ ������. ��� ��������� ��������� ������� � ������ ����� — ���������� ���� ��� ��������� ���� ���������� �������� «N».
KEY — ������������ ���� �������� � ����� /bitrix/license_key.php ������: |
key | ������ ���������� ����� ������������ ������ ��� ������ ������� /bitrix/admin/phpinfo.php. ���� �� �������� ����� ������ ������������� �����, �� �������������� ������ ���������� ��� ����������� ����������������� �������.
������: |
����������� ����� ����������:
- � (����������) — ���������� ������������� �������� � ��������� ����� �������
- � (���������� � �����) — ���������� ����� ���������� ������ � ����� �������� ��������� ���������� � ����: /bitrix/php_interface/dbconn.php
- � (�������������) — ���������� ����� ���������� � ����� �� ��������� ������:
- /bitrix/php_interface/init.php — �������������� ��������� �������
- /bitrix/php_interface/ID �����/init.php — �������������� ��������� �����
- � (��������) — ���������� ����� ������ � ���������� �������� ��� �������� �� � ��������
���������������� �����������
�� ����� ����, ���� ������������ ������� ���� ����������� �� ������������� ������������� ������� �������.
��� ����� ����� ����� ���� �������������� �� �����
�� �������, ��� ���������������� �����������, �������� �� ���������, �� �������� ����������� �������������. ��������������� �� �� ������������� ����� ��� ������������.
����� ���������������� ����������� �� �������� ������ ��� ���������� �����������. �� �������� �������� ����������� �� ������.
[Tech] ��������������� ���������
���������� ��� ���������������� ������ ����� � ����� — /vendor/neTpyceB/TMCms/src/Boot.php
SELF — ������� ����� �������� (��������, /en/about-us/)
HOST — ������� ����� (��������, example.com)
BASE_URL — ���������� ������� ����� (� ������ �������� �������) ��������, — https | http :// example.com)
REF — ���������� ����� �������� (���� ����), ������� ������� ������� ������������ �� ������ ��������.(php = $_SERVER[‘HTTP_REFERER’])
NOW — ���������� ������� ����� ������� Unix (1459596827)
���������� ������ � ���������������� ��������� � PHP
� PHP ������� ����� ����������� ���������������� �������� � ���������� ������� ��� ����� ��������. � ������� �� ������� ��������, ������� ����� ������������� � ������� define() , �������� ���������������� �������� ������� �� ����, ��� ��� ������������, � �������� ����������� ������ ��� ������ � ���� � PHP �������. ���������� ������ ����� ������������ � ����� ������� ��� ��������� ������� � ������������ ����������� PHP.
� ������ ����� �� ���������� ��������� �������� ���������������� �������� � ���������� ������� � ��������� ������������� � ����.
���������������� ���������
��������������� ��������� ������������ ��� ��������� ���������� � ����� ����. ��� ����� ��������� ������� ���������� ������� ����� ���������� ���������������, ��������, __LINE__ � __FILE__ . ��� ��������� �������� ��������������� ��������, ��������� � PHP:
-
__LINE__ ���������� ����� ������ � �������� �����, ��� ������������ ���������:
���������� ������
���������� ������ ������������ ������ ��� ������������ ����������� PHP. �� ����� ������� ���������� ������� � ����� ��������������� ���������������, ��������, __construct() � __destruct() .
__construct() — ���������� �����, ������� PHP �������� ��� �������� ���������� ������ ������. �� ��������� ����� ���������� ����������.
__destruct()- ���������� �����, ������� ����������, ����� ������ ������������ ����������� PHP. ������ ����� �� ��������� ���������� � ������ ������������ ��� ���������� ����������� ��������, ��������, ��� �������� ���������� � ����� ������.
��������� ��������� ���������� ������� ������������� ��� ����������� �� ����������, � ������������ ������ ��� PHP ���������� ��������� �� ��������� � �������, ������� �� ���� ���������� (��� ����������).
PHP �������� ����� __get() � ���������� ���������, ���� �������� �� ���������� (��� ����������). ����� ��������� ���� �������� — ��� ��������. �� ������ ������� ��������, ������� ����� �������������� ��� �������� ��������.
����� __set() ���������� ��� ��������������� �������� � �������� ���������. ������ ����� ��������� ��� ���������, ��� �������� � ��������.
� ���� ����������� ���� �������� name �� ���������� � ������. � ���� ��������������� ������� ��������� ������� �������� �������� �Alireza� � PHP �������� ���������� ����� __set() . �� �������� �name� � �������� ��������� $prop � �Alireza� ��� $value , � ��������� �������� � ������� ������� $myArray . ����� __get() �������� � ������ ������. ��� ������ $obj->name ���������� ����� __get() � ��� ���������� �������� �name� ��� �������� $prop .
���� � ������ ���������� ������, ������� �������� �������������� ������������ ����������, ��� � ����������� �������: __isset() , __unset() � __toString() . ��� ������ __isset() � __unset() ����������� ��������� � ������ �� �������, �� ��� ������������� � PHP.
__isset() ���������, ����������� �������� ��� ���. ������ ����� ��������� ���� �������� — ��������, ������� ���� ���������. ����� __unset() ��������� ���� ��������, ��� ��������, ������� ����� ��������.
�� ������ ������� ������ ������������� ������� ��� ������, ��������, ��� ������ ������������ ��� ������� ��������. ������ PHP ������������ ������ ��� ������������� � ������, ��� ����� ��� ����� �������. ����� __toString() �������� ����������� ������ ��� ������. ����� ����������� �� ������ ���������, ��� ������ ������������ ��� ������, ��������, echo «Hello $obj» . ����� ��� ����� ������� ���������������, ��� ����� ������ ��������� �����.
������ ���� ����������� ��� ��� �������� ����� ruseller.com
�������� �����: phpmaster.com/magic-methods-and-predefined-constants-in-php/
�������: ������ ��������
���� ������: 26 ������ 2012
����������: 25627
������� �����������
5 ��������� ������ ������� «PHP»
���������� ������ � ������� zend-filter
����� ���� ��� � ������������ ���-�����, �� ����� «���������� ��, ����������� ��» ������ ����� ���������. ������� ��������� � ���������� ������.
����������� ������������� � ������� zend-escaper
����������� ������������ ���-����� � ��� �� ������ ������ �� SQL ��������, �� � ��������� �� ������������ ���������� (XSS), ����������� �������� �������� (CSRF) � �� ������ ����� ����. � ���������, ��� ����� ����� ��������� ��������� � ������������ HTML, CSS � JavaScript ����.
����������� Zend ������� � Expressive
Expressive 2 ������������ ����������� ����������� ������ ZF ��������� �� ����������� �����. �� ���� �������� ������ �������. � ���� ������ �� ��������� ��� �������� ������� ����������� ���������� �������.
�����: �������� ���������� � Google Analytics ����� API
�����������, ��� ��� ���������� ��������� �����-�� ���������� � Google Analytics �� ���������� �������. ��� ��� �������. ����� � ���� �������.
�������� PHP ��������
�������� �� ���������� ����� PHP ��������. �� ��������� �� � ������ online ������� ��������� ���� ���, �� ���� ��� �� �������, ������� ����� �������� �� ���� ����.
������� ��������� � �������
��������� ������ � PHP — ��� ������ ���������� ����������� ������ � ������� ��������������� ����������� ��������. ��� ��� ����������� ������� ����� ������������������ ���������� � ��������� ����������������� ������ web-�����.
���� �� ������� � ������������� ������ � ������� PHPLIB, �� ��������, ��� ��������� ������� ���������� ��������� ������ � PHP.
���������� ������ ����� ������������� ���������� id, ��� ���������� session id. �� �������� � ���� �� ������� ������������ ��� �������� � URL.
��������� ������ � �������� ��� ��� ����������� �������������� ������������ ���������� ���������� � ��������� �� � ����������� ����� ������������ ��������. ����� ������������ ������� �� ��� ����, PHP ����� ������������� (���� session.auto_start ����� �������� 1) ��� �� ������ ������� (���� — ����� session_start() ��� ������ — ����� session_register() ) ���������, ������ �� ������������� session id ������ � ��������. ���� ��� ���, ����������� �������������� ���������.
��� ������������������ ���������� ������������� ����� ��������� �������. ������������������ undefined-���������� ����������� ��� �� �����������. ��� ����������� �������� ��� �� ������������ ������� ������, ���� ������ ������������ �� ���������� �� �������.
��������� ������������ track_vars � register_globals ����������, ��� ���������� ������ �������� � �����������������.
����������: � PHP 4.1.0 $_SESSION �������� ��� ���������� ����������, ������ ��� $_POST , $_GET , $_REQUEST � ��� �����. � ������� �� $HTTP_SESSION_VARS , $_SESSION ������ ���������. �������������, global �� ������ �������������� ��� $_SESSION .
���� track_vars ��������, � register_globals ���������, ������ ����� ����������� �������������� ������� $HTTP_SESSION_VARS ����� ���� ���������������� ��� ���������� ������. ��������������� ���������� ������ ����� �������� ������ � ������� $HTTP_SESSION_VARS .
(); // ����������� $HTTP_SESSION_VARS � PHP 4.0.6 ��� ����� if (!isset( $_SESSION [ ‘count’ ])) < $_SESSION [ ‘count’ ] = 0 ; > else < $_SESSION [ ‘count’ ]++; > ?> |
������������� $_SESSION (��� $HTTP_SESSION_VARS � PHP 4.0.6 ��� �����) ������������� �� ����������� ������������ � ���������� ����. ��� ������� ���������� $_SESSION ��� $HTTP_SESSION_VARS ��� ������������� ������������ ������� session_register()/session_unregister()/session_is_registered(). ������������ ����� �������� ������ � ���������� ������ ��� � ���������� ����������.
(); // Use $HTTP_SESSION_VARS with PHP 4.0.6 or less unset( $_SESSION [ ‘count’ ]); ?> |
���� register_globals ��������, �� ��� ���������� ���������� ����� ���� ���������������� ��� ���������� ������, � ���������� ������ ����� ����������������� � ��������������� ���������� ����������. ��������� PHP ������ �����, ����� ���������� ���������� ���������������� ��� ���������� ������, ������������ ������ �������������� ���������� �������� session_register(), � �� ����� ��� $HTTP_SESSION_VARS / $_SESSION �� ������ ������������ session_register().
��������! |
---|
(); // � PHP 4.3 � �����, �� ������ ������ ������������ �������������� ������: session_unregister ( ‘count’ ); ?> |
���� track_vars � register_globals ��������, �� ��������� ���������� ���������� � $HTTP_SESSION_VARS / $_SESSION ����� ��������� �� �� �� ����� �������� ��� ��� ������������������ ����������.
������ 4. ����������� �����, ����� register_globals ��������
if (! isset( $_SESSION [ ‘count’ ])) < $_SESSION [ ‘count’ ] = 1 ; > else < $_SESSION [ ‘count’ ]++; > ?> |
���� ������������ ��������� session_register() ��� ����������� ���������� ������, $HTTP_SESSION_VARS / $_SESSION �� ����� ����� ��� ���������� � �������, ���� �� �� ����� �������� �� ��������� ������ (�.�. �� ���������� �������).
���� ��� ������ �������� session id:
������ ������ ������������ ��� ������. ���� �������� ������������, ��, ��������� ��� �������� (������� ����� �� �� ���������), �� �� ����� ���������� �� ���. ������ ����� �������� session id ��������������� � URL.
PHP �������� ������ ��� ��������� ��� �������������� � ������ —enable-trans-sid . ���� �� �������� ��� �����, ������������� URI ��������� � ����� ��������� session id �������������. ������������� �� ������ ������������ ��������� SID , ������� ����������, ���� ������ �� �������� ��������������� ����. SID ����� ����� session_name=session_id ��� ������ ������.
����������: ��������� arg_separator.output php.ini ��������� ���������������� ����������� ����������.
��������� ������ �������������, ��� ���������������� ���������� � ��� ��������� ��������� � ������ ���������, ��������� S >
������ 5. ������� ���������� ������ ���������� ������������
if (! session_is_registered ( ‘count’ )) < session_register ( ‘count’ ); $count = 1 ; > else < $count ++; > ?> Hello visitor, you have seen this page echo $count ; ?> times. �� �����, ���� —enable-trans-sid �������������� ��� ���������� PHP.
��� ���������� �������� � �� ��� ������� ������ ��� ����������� ������������ session_set_save_handler() ��� �������� ������ ������� �������� ������ ������������. ���������� ���������������� ��������� �� ���������:
������� ����������� ������ ������������ ��������� ����� ������������, ������� �� ������ ��������� � ��� ���� php.ini . �� ����� ������� �����. session.save_handler ���������� ��� ����������� �������� � ������������ ������, ��������������� � �������. �� ��������� files . session.save_path ���������� ��������, ������� ��������� ��� �������� �����������. ���� �� ������� ���������� ������ �� ���������, ��� ����� ���� � ����� �������� ������. �� ��������� /tmp . ���� ������� ���� ��� session.save_path ������ 2, ������ ������ �� ����� �����������.
|