Skip to content

Instantly share code, notes, and snippets.

View fabioluciano's full-sized avatar
🏠
Working from home

Fábio Luciano fabioluciano

🏠
Working from home
View GitHub Profile
<?php
$array = [
'isto', 'eh', 'um', 'array', 'com', 'varios', 'itens', 'e', 'indice', 'numerico'
];
print_r($array);
/* output
Array
<?php
$array = [
'isto', 'eh', 'um', 'array', 'com', 'varios', 'itens', 'e', 'indice', 'numerico'
];
echo implode(' ', $array);
//output: isto eh um array com varios itens e indice numerico
<?php
$frutas = [
'banana' => 'amarela', 'limao' => 'verde', 'morango' => 'vermelho'
];
echo $frutas['limao'] . PHP_EOL;
echo end($frutas) . PHP_EOL;
/* output
verde
<?php
namespace test;
final class Test
{
public static function testMethod(array $list = [])
{
return implode(' ', $list);
}
}
<?php
$url = 'http://google.com';
echo 'host:' . parse_url($url)['host'] . PHP_EOL;
echo 'scheme:' . parse_url($url)['scheme'];
/*
output
host:google.com
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="UTF-8" />
<title>base64</title></title>
<script type='text/javascript' src='js.js'></script>
<link rel="stylesheet" href="css.css" type="text/css" media="screen" />
</head>
<body>
<div class="image-list">
<?php
final class DataUri {
protected $file;
public function __construct($file) {
$this->file = $file;
return $this;
data:image/jpeg; charset=binary;base64,/9j/4AAQSkZJRgABAQABLAEsAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAHbAdkDASIAAhEBAxEB/8QAHQAAAgIDAQEBAAAAAAAAAAAAAAECBAMFBgcICf/EAEwQAAEDAwIDBAcDCgMGBQQDAAEAAgMEBREhMQYSQRNRYXEHFCIygZGhUrHBFSMkM0JDU2Jy0XOS4RY0Y4OToggXNkSCJjVVsmTi8f/EABkBAAMBAQEAAAAAAAAAAAAAAAABAgMEBf/EACMRAQEAAwABBQEAAwEAAAAAAAABAgMREgQTFCExQSIyUWH/2gAMAwEAAhEDEQA/APpBCSApBoQUgkDQhBSSCkhCFAJ5Heq1TN2Ubiq1rqXTF4cp8vvi5PpskJIVopoSCZTB5TCx5UgUgkUksoKRwykEsoSVxkBwDqlzZ6qJKQTJMnRJrtVEoB10QbIXZSOyxySMiaXyuaxo3LjgBc5cOOeHqOUwyXGOWUfsU7XSn/tBSuRzCumQN1wk3pDieSKC03CcdHPaIQf82v0VKXjm+OP6PaKGFv8Axqpzj8msH3qPOK9uvSeiWV5c/i3imQ5a60RDu7F7z9XBYX8Q8USb3GgZ/RR/3cUvdxV7NesBB2XkovfE2db20DubSRj7wVL8u8St1F4if4PpGa/LCPdh+xXq+UwcFeWx8U8Tx/8AuLdJ/XTEfc5WIeM+IGHM1Ja5/wCl8kZ+4om2FdFemE6JDdefR+kGZjsVlhqmj7VPMyUfI8pW2o+PeH5uVlRUy0UvUVUL4/qRj6q/OJ9uutJwol+ir01ZT1kfaUlRFPE7Z0bg4H5LKn1Fx
<?php require_once 'DataUri.php'; ?>
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="UTF-8" />
<title>base64</title></title>
<script type='text/javascript' src='js.js'></script>
<link rel="stylesheet" href="css.css" type="text/css" media="screen" />
</head>
<body>
<?php
$obj = Test::testMethod('Isso é uma string');
/* output:
Catchable fatal error: Argument 1 passed to test\Test::testMethod() must be an array, string given,
*/