class Demo {
static private $db = null;
static private $cache = [];
static protected function getDb() {
if(self::$db === null) {
self::$db = ... // init $db
}
return self::$db;
}
static protected function cachedAction($arg) {
if(!array_key_exist($arg, self::$cache)) {
self::$cache[$arg] = ... // do action
}
return self::$cache[$arg];
}
}
class DemoChild : public Demo {
}
$a = new Demo();
$b = new DemoChild();
$a->getDb()->query();
$b->getDb()->query(); // uses the same connection
$c = $a->cachedAction('one');
$d = $b->cachedAction('one'); // no action, cache used
private function check($jsonData) {
return $this->apiUrl = $jsonData['next_page_url'] ?? null;
}
if( $i % 3 === 1 ) :
action="masterpanel.php"
<input type="hidden" name="master" value="<?= $_GET['master'] ?>" />
<?php
$name = require_once(__DIR__ . "/config.php");
echo $name;
// config.php
<?php
return "TEST";
Просто я, живя в мегаполисе, вижу, что вакансий без битрикса\ВП и фреймворков - процентов 10 от рынка, вопрос: а нужно ли вообще уделять PHP без фреймворков большое внимание
Насколько я понял, php в какой-то момент
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Файл корректен и был успешно загружен.\n";
} else if($_FILES['userfile']['error'] === UPLOAD_ERR_FORM_SIZE) {
echo "А кто будет настраивать сервер под файло таких размеров?\n";
}
server {
listen 80;
#listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
server_name my-site.com *.my-site.com;
charset utf-8;
access_log /var/www/logs/access.nginx.log;
error_log /var/www/logs/error.nginx.log error;
set $subdomain "www";
if ($host ~* ^([-a-z0-9]+)\.my-site\.com$) {
set $subdomain $1;
}
if ($host ~* ^www\.my-site\.com$) {
rewrite ^/(.*)$ http://my-site.com/$1 permanent;
}
root /var/www/$subdomain/public;
client_max_body_size 32M;
location / {
rewrite ^/.*$ /index.php last;
}
# Pass the PHP scripts to FastCGI server
location ~ ^/index.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}