Skip to content

Instantly share code, notes, and snippets.

View nurullahisik's full-sized avatar
😎
funny

NURULLAH IŞIK nurullahisik

😎
funny
View GitHub Profile
<?php
/* Example 2 */
// yes, the argument list can be empty
function foo() {
// returns an array of all passed arguments
$args = func_get_args();
foreach ($args[0] as $k => $v) {
<?php
/* Example 1 */
// yes, the argument list can be empty
function foo() {
// returns an array of all passed arguments
$args = func_get_args();
foreach ($args as $k => $v) {
@nurullahisik
nurullahisik / global-variable.php
Created February 18, 2019 13:37
Global Variable
<?php
global $x;
$x = "asd";
asd();
function asd()
{
global $x;
@nurullahisik
nurullahisik / fopen-remote-host
Created February 13, 2019 06:51
Storing data on a remote server
<?php
$dosya = fopen ("ftp://kullanici:[email protected]_bir_site.com/gelen/yazilan_dosya", "w");
if (!$dosya) {
echo "<p>Uzak dosya yazmak için açılamıyor.\n";
exit;
}
/* Veriyi burada yaz. */
fwrite ($dosya, $_SERVER['HTTP_USER_AGENT'] . "\n");
fclose ($dosya);
?>
@nurullahisik
nurullahisik / memory-test.php
Last active March 1, 2019 08:04
PHP Memory Test
<?php
class Foo
{
public $var = '3.14159265359';
}
$baseMemory = memory_get_usage();
for ( $i = 0; $i <= 100000; $i++ )
{
@nurullahisik
nurullahisik / session_reset.php
Last active February 12, 2019 12:43
Session Reset
<?php
session_start();
$_SESSION["A"] = "Some New Value"; // set new value
print_r($_SESSION);
$_SESSION["B"] = "Some New Value"; // set new value
$_SESSION["C"] = "Some New Value"; // set new value
print_r($_SESSION);
session_reset(); // old session value restored
print_r($_SESSION);
@nurullahisik
nurullahisik / user_agent.php
Last active February 12, 2019 12:43
Get User Agent with PHP
<?php
function getBrowser()
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
//First get the platform?
if (preg_match('/linux/i', $u_agent)) {
@nurullahisik
nurullahisik / tempnam.php
Last active February 12, 2019 12:44
Create file with unique file name With PHP
<?php
$temp_file = tempnam("/", "FOO");
echo $temp_file;
// $file = fopen($temp_file, "w");
// fwrite($file, "temp file content");
// fclose($file);
@nurullahisik
nurullahisik / gist:6664ca53faec666f9415e7e2e31569e9
Last active February 12, 2019 12:45
get server ram with php
<?php
$fh = fopen('/proc/meminfo','r');
$mem = 0;
while ($line = fgets($fh)) {
$pieces = array();
if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) {
$mem = $pieces[1];
break;
}
}
"autoload": {
"classmap": [
...
],
"psr-4": {
"App\\": "app/"
},
"files\\": [
"app/helpers.php"
]