{"id":2488,"date":"2015-07-02T14:20:39","date_gmt":"2015-07-02T14:20:39","guid":{"rendered":"http:\/\/musilda.cz\/?p=2488"},"modified":"2015-07-02T14:20:39","modified_gmt":"2015-07-02T14:20:39","slug":"php-4-constructor-ve-wordpressu-4-3","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/php-4-constructor-ve-wordpressu-4-3\/","title":{"rendered":"PHP 4 constructor ve WordPressu 4.3"},"content":{"rendered":"

Proto\u017ee je na tento rok ohl\u00e1\u0161en\u00e1 PHP verze 7 a krom\u011b jin\u00fdch zm\u011bn v sob\u011b obsahuje zavr\u017een\u00ed konstruktoru t\u0159\u00eddy v PHP 4. Z tohoto d\u016fvodu budou v\u0161echny t\u0159\u00eddy ve WordPressu 4.3 a v\u00fd\u0161e, pou\u017e\u00edvat konstruktory zaveden\u00e9 od PHP 5.<\/p>\n

O co p\u0159esn\u011b jde.<\/p>\n

V PHP 4 jste zavolali kontruktor t\u0159\u00eddy pomoc\u00ed funkce, jen\u017e m\u011bla stejn\u00fd n\u00e1zev, jako samotn\u00e1 t\u0159\u00edda.<\/p>\n

\nclass MyClass {\n\n  function myclass(){\n     \/\/ K\u00f3d konstruktoru\n  }\n\n}\n<\/pre>\n

Od verze PHP 5 se konstruktor vyvolal pomoc\u00ed funkce __construct<\/p>\n

\nclass MyClass {\n\n  function __construct(){\n     \/\/ K\u00f3d konstruktoru\n  }\n\n}\n<\/pre>\n

A proto\u017ee od sedmi\u010dkov\u00e9 verze bude podpora \u010dty\u0159kov\u00fd konstruktor\u016f zru\u0161ena, v\u0161echny t\u0159\u00eddy j\u00e1dra WordPressu budou pou\u017e\u00edvat p\u011btkov\u00fd konstruktor.<\/p>\n

V r\u00e1mci a\u017e fanatick\u00e9m lp\u011bn\u00ed na zp\u011btn\u00e9 kompatibilit\u011b, z\u016fstanou ve t\u0159\u00edd\u00e1ch pohrobci, umo\u017e\u0148uj\u00edc\u00ed vyu\u017e\u00edt konstruktor z PHP 4.<\/p>\n

\nclass MyClass {\n\n  function __construct(){\n     \/\/ K\u00f3d konstruktoru\n  }\n\n  function myclass(){\n     self::__construct();\n  }\n\n}\n<\/pre>\n

Co to znamen\u00e1 pro n\u00e1s? V podstat\u011b jen to, \u017ee pokud pou\u017e\u00edv\u00e1te n\u011bjakou t\u0159\u00eddu, kter\u00e1 vol\u00e1 \u010dty\u0159kov\u00fd konstruktor rodi\u010dovsk\u00e9 t\u0159\u00eddy, typicky widget t\u0159\u00eddy, M\u011bli by jste jej volat jako parent::__contructor().<\/p>\n","protected":false},"excerpt":{"rendered":"

Proto\u017ee je na tento rok ohl\u00e1\u0161en\u00e1 PHP verze 7 a krom\u011b jin\u00fdch zm\u011bn v sob\u011b obsahuje zavr\u017een\u00ed konstruktoru t\u0159\u00eddy v PHP 4. Z tohoto d\u016fvodu budou v\u0161echny t\u0159\u00eddy ve WordPressu 4.3 a v\u00fd\u0161e, pou\u017e\u00edvat konstruktory zaveden\u00e9 od PHP 5. O co p\u0159esn\u011b jde. V PHP 4 jste zavolali kontruktor t\u0159\u00eddy pomoc\u00ed funkce, jen\u017e m\u011bla stejn\u00fd<\/p>\n","protected":false},"author":1,"featured_media":2286,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[279,484],"class_list":["post-2488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-php4","tag-wordpress-core"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2488"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=2488"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2488\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2286"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}