Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
The built-in function
http_response_code
Sets HTTP response status code
404
http_response_code(404);
by Valeri Tandilashvili
4 years ago
0
PHP
functions
1
Registers a function that will be executed right before the PHP process stops execution
register_shutdown_function('myexit');

function myexit()
{
	echo "</schedule>";
}
by Valeri Tandilashvili
4 years ago
0
PHP
functions
PHP official doc
1
spread operator clone
// spread operator

let method1 = {...car}
// method1 === car  // false
// method1.model = "F150"
// let sprd = {...car, color: "black", model:"ranger"}
if the comparison returns false so it cloned successfully because they will refer to a different location on memory. So we can add or update properties with another parameters after spread operator..
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
rest operator clone
// rest operator

let {...method2} = car
// let {model, ...rst} = car
// let {model, ...car} = {year:"2017", ...car}
rest operator is allows us to skip some propoerties.. we can also use it with spread operator and it will more useful because it can add or update properties at the same time
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
json.parse to clone object
let method4 = JSON.parse(JSON.stringify(car))
// JSON.stringify(car)
// JSON.parse('{"mark":"Ford","model":"Raptor"}')

JSON.PARSE method just converts it into a string then parses so it can clone nested objects too
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };

const returnedTarget = Object.assign(target, source);
// using object.assign method first object will be simply concatenated to second one
also we can write empty {} brackets and set it empty object as a first argument
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
not deep clone

function clone(obj) {
    let clone = {};

    for(let i in obj){
        if(obj[i] != null && typeof(obj[i]) == "object")
            clone[i] = clone(obj[i])
        else
            clone[i] = obj[i];
    }

    return clone;
}
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
deep clone with properties

function deepClone(obj) {
    let copy = {};

    if (null == obj || "object" != typeof obj) return obj;

    copy  = Object.create(obj.constructor.prototype)
    for (let key in obj){
        copy[key] = clone(obj[key])
    }
    return copy
}
by Luka Tatarishvili
4 years ago
0
JavaScript
Objects tutorial 6
0
getmypid
- Gets PHP's process ID
echo 'Current process ID:' . getmypid();
The output will be:
Current process ID:4868
by Valeri Tandilashvili
5 years ago
0
PHP
functions
1
$argv
contains filename and parameters, when the
php script
is called through command line (cmd).
test_args.php
file content:
<?php

echo 'Filename:'.$argv[0].";  ";
echo 'First parameter:'.$argv[1].";  ";
echo 'Second parameter:'.$argv[2].";  ";
If we run the command:
php test_args.php first-param second-param
in
cmd
the script above will output the following:
Filename:test_args.php;  First parameter:first-param;  Second parameter:second-param;
by Valeri Tandilashvili
5 years ago
0
PHP
1
Results: 1578