Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Check if the key "Volvo" exists in an array:
<?php
$a=array("Volvo"=>"XC90","BMW"=>"X5");
if (array_key_exists("Volvo",$a))
  {
  echo "Key exists!";
  }
else
  {
  echo "Key does not exist!";
  }
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
1
Return an array containing the keys:
<?php
$a=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander");
print_r(array_keys($a));
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
1
Check whether a variable is an object or not:
<?php
function get_cars($obj) {
  if (!is_object($obj)) {
    return false;
  }
return $obj->cars;
}

$obj = new stdClass();
$obj->cars = array("Volvo", "BMW", "Audi");

var_dump(get_cars(null));
echo "<br>";
var_dump(get_cars($obj));
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Variable Handling
PHP official doc
1
1) Clear sql file from unnecessary lines and leave only
insert
query For example:
INSERT INTO `topwords` (`id`, `word`, `frequency`, `deleted`) VALUES
(1, 'the', 22038615, 0),
(2, 'be', 12545825, 0)
...
2) Add SQL file in a public folder or App/someFolderForSQLFiles 3) Use this in seeder
  $path = base_path('public\topwords.sql');
        $sql = file_get_contents($path);
        DB::unprepared($sql);
Or this:
 $path = 'app/someFolderForSQLFiles/topwords.sql';
 DB::unprepared(file_get_contents($path));
by Luka Tatarishvili
4 years ago
2
Laravel
Seeders
1
ON DUPLICATE KEY UPDATE
Updates
paramVal
field if the row exists, otherwise inserts as a new row
INSERT INTO sysData (paramName, paramVal) 
VALUES ('payprocess', 1) 

ON DUPLICATE KEY 

UPDATE paramVal = 1 WHERE paramName = 'payprocess';
by Valeri Tandilashvili
4 years ago
0
MySQL
UPDATE
1
increase buffer size
The following issue:
...upstream sent too big header while reading response header from upstream...
Is fixed by adding these lines:
fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
To the site's configuration file:
server {
    listen 80;
    server_name pm.use.ge;
    root /var/www/pm.use.ge/public_html;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

        include fastcgi_params;                                                                                                                                >        deny all;
    }
}
So that the final configuration file looks like this:
server {
    listen 80;
    server_name pm.use.ge;
    root /var/www/pm.use.ge/public_html;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

        fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
        fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        include fastcgi_params;                                                                                                                                >        deny all;
    }
}
by Valeri Tandilashvili
4 years ago
0
Linux
1
(or|and|(?:(?P<case1namE>)\() ?|) ?\w*(\.)?colz( like| ?\=) ?\?(?:(?P=case1namE) OR)?( and)?
in this case if
(
is found before the expression then
OR
will be captured at the end of the expression(if found) IMPORTANT: group name is case sensitive //see code for real example
by გიორგი უზნაძე
4 years ago
0
PHP
Regexp
1
disable google crawler bot using meta tag
if you don't want google to crawl in your website and add it in search engine database use this tag to avoid it
<meta name="robots" content="noindex, nofollow">
by გიორგი უზნაძე
4 years ago
0
HTML
SEO
1
method_exists() does not care about the existence of
__call()
, whereas
is_callable()
does:
<?php
class Test {
  public function explicit(  ) {
      // ...
  }
  
  public function __call( $meth, $args ) {
      // ...
  }
}

$Tester = new Test();

var_export(method_exists($Tester, 'anything')); // false
var_export(is_callable(array($Tester, 'anything'))); // true
?>
by გიორგი უზნაძე
4 years ago
3
PHP
Objects
1
$font-weights: (
    "regular": 400,
    "medium": 500,
    "bold": 700
);

//now if we want to apply it we have to use 'map-get' function
body {
    font-weight: map-get($font-weights, "medium");
}
.some-class{
    font-weight: map-get($font-weights, "bold")
}
by გიორგი უზნაძე
4 years ago
0
Sass
Array
1
Results: 1580