Posts by Paulo Freitas • 754 points
9 posts
- 
		4 votes3 answers189 viewsA: What happens in the expression "$a+++(+$a)"?Initial state: $a = 0; $x = $a+++(++$a); When the post-increment operation of $a++ is evaluated, $a still worth 0. We have at this time: $x = 0 + (++$a); $a = 1; When evaluating the pre-increment… 
- 
		3 votes2 answers3927 viewsA: How to edit the routes created by make:auth?In this specific case to change the views you will want to follow the recommendation of friend @Wallace Maxters. This is the recommended way. ;) If you need to customize routes, you can simply… 
- 
		3 votes2 answers234 viewsA: How to globally set the default date output in Laravel 5?Write over the method serializeDate() aggregated by the trait Illuminate\Database\Eloquent\Concerns\HasAttributes in their models. You can do this by extending your models from an abstract class… 
- 
		11 votes5 answers22797 viewsA: How to invert dates in PHP, regardless of format?Based on what has been described... function swap_date($date_str) { if ($date = \DateTime::createFromFormat('Y-m-d', $date_str)) { return $date->format('d/m/Y'); } elseif ($date =… 
- 
		2 votes5 answers989 viewsA: How to remove an Element from an XML with Python?I recommend using the library lxml for the performance and simplicity of the: from lxml import etree gpx = etree.parse(open('input.gpx')) for node in gpx.xpath('//trkpt/extensions'):… 
- 
		2 votes3 answers1094 viewsA: Assign value to a dictionary variable that is optionalOne way around the problem presented by @mgibsonbr is to return a copy of the dictionary instead: def uma_funcao(um_dict={}): um_dict['uma_chave'] = True return um_dict.copy() Note that, if um_dict… 
- 
		8 votes2 answers1735 viewsA: Date being recorded wrong in m-d-Y bank instead of Y-m-dIn your controller, in the method postEdit(), change this line: $dados['data'] = date('Y/m/d', strtotime($dados['data'])); For this: $dados['data'] = DateTime::createFromFormat('d/m/Y',… 
- 
		0 votes5 answers1837 viewsA: How to create a configuration file in Laravel 4?Note that to change these settings, the Config::set() will not save the file as you might expect. You will have to implement this on your own, and in the case of PHP configuration files where you… 
- 
		4 votes7 answers59028 viewsA: Refactoring function to remove punctuation, spaces and special charactersYou look for the function strtr(). Regular expressions help to deal with exceptional cases: function sanitizeString($str) { return preg_replace('{\W}', '', preg_replace('{ +}', '_', strtr(…