View image_encode_base64.php
<?php
$filename = 'anhaenger.jpg';
//$filename = 'anhaenger.png';
$path = 'img/' . $filename;
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
file_put_contents('base64/' . substr($filename, 0, (strrpos($filename, '.'))), $base64);
echo $base64;
View svg_from_file_with_d3.js
const fs = require('fs');
const d3 = require('d3');
const D3Node = require('d3-node');
var jsdom = require('jsdom');
const { JSDOM } = jsdom;
var contents = fs.readFileSync(__dirname + '/data/rectangle_100.svg', 'utf8');
// console.log(contents);
const dom = new JSDOM(contents);
// console.log(dom.window.document.querySelector('svg').outerHTML);
View multiple_namespaces_in_a_file.php
<?php
namespace A {
$closure = function () {
echo __NAMESPACE__;
};
}
namespace B {
$closure = function () {
View zf2_controller-with-viewHelper.php
<?php
namespace MyApp\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use \Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
class IndexController extends AbstractActionController
{
View php_baseurl.php
<?php
$baseUrl = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))) . '://' . $_SERVER['SERVER_NAME'];
View js_stringToUpperFirst.js
function stringToUpperFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
View ZF2_log-SQL-string-with-driver-support.php
<?php
namespace BitkornShop\Table\Basket;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\HydratingResultSet;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Adapter\AdapterAwareInterface;
/**
View zf2_short_fetch_all_tablex.php
<?php
namespace Foo;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\ParameterContainer;
class A
{
View zf2_table_lastInsertValue.php
<?php
/**
*
* @param array $data
* @return int
*/
public function insertSomeAndGetLastInsertValue(array $data)
{
$insert = $this->sql->insert();
$insert->values($data);
View zf2_base-url_in_controller_and_view.php
<?php
$uri = $this->getRequest()->getUri();
$base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
// or
$serverUrlHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('ServerUrl');
$url = $serverUrlHelper($this->url()->fromRoute('some_routename'));
// or in view
echo $this->serverUrl($this->url('some_routename'))