Posts by Bruno Augusto • 8,661 points
187 posts
-
2
votes2
answers111
viewsA: Activation e-mail
I will not respond based on Codeigniter either because it does not work with Codeigniter and also because it would limit the use of the response only to those who use this framework. User activation…
codeigniteranswered Bruno Augusto 8,661 -
2
votes3
answers3696
viewsA: Merge arrays in php
I really wanted to see another one of those wild tricks that would solve the problem without iterating but, if it’s not a problem: foreach( $names as $offset => $name ) { $data[] = array( 'name'…
-
2
votes3
answers158
viewsA: preg_replace_callback does not work
Good that solved, but I need to consider some points and even explain why your code didn’t work as you expected. create_function() is not only a dangerous resource because it is subject to all…
-
4
votes1
answer142
viewsA: How are unofficial Apis made?
The vast majority of unofficial Apis work well anyway. The first most important step is to read carefully the Term of Use, if any. If there are no restrictions, you begin to outline the your…
apianswered Bruno Augusto 8,661 -
1
votes5
answers74116
viewsA: Removing a specific element in an array
And if the array you search for is multidimensional, a complement to the answer do @Sergio, would be a function originated in the comments of the PHP manual (but today, unfortunately lost) that…
-
26
votes2
answers31112
viewsA: When to use ANSI and when to use UTF-8?
TL;DR UTF-8 is a widely used scheme whereas ANSI is virtually obsolete. ANSI uses a single byte whereas UTF-8 uses an encoding multibyte. UTF-8 can represent a much larger character range than the…
-
6
votes2
answers1630
viewsA: In php how to run a function after past X days of last run
A possibility would be something like having at least the path location of the files and the information returned by filemtime() of each of them stored in a database. Accessed by a given URL, you…
-
1
votes2
answers51
viewsA: Filter Useagent Via Database
Amid the many researches I did when actively programming, I came to elaborate this class to obtain various information about the user’s browser. The use, assuming the class has been included, is…
-
2
votes2
answers2364
viewsA: About Object Oriented in PHP
TL;DR Class methods are subject to scope restrictions such as functions. In order for a resource in the global, external scope to work in the local scope of the method, you have to globalize the…
-
3
votes2
answers2346
viewsA: Code indentation spacing standardization
DEPENDS A LOT ON coding standards application (or layout as is your case) and still programmer. Some leftists defend the use of TAB because it is somewhat universal, but this is counter-argued by…
htmlanswered Bruno Augusto 8,661 -
4
votes2
answers428
viewsA: General questions about using xhtml box, positioning and width
Your question is rather confusing and in some ways too broad, but I believe I can answer. I can’t give you a verdict on using float or margin to position elements but use float brings as its main…
-
4
votes4
answers2195
viewsA: Fetch date 7 days before current php date
The class Datetime is much more preferable to handle date/time and relative: <?php date_default_timezone_set( 'America/Sao_Paulo' ); $time = new DateTime( '2014-07-29' ); print '<pre>';…
phpanswered Bruno Augusto 8,661 -
2
votes2
answers149
viewsA: Combo does not load with calling via jquery
I’m glad you solved the problem on your own, but I believe a better explanation of why it happens is valid. The Event ready occurs afterward that the HTML document is loaded while the Event onload…
-
5
votes2
answers1312
viewsA: Retrieve cookie expiration time in javascript or jquery
You simply cannot get this kind of information with Javascript because it is not available at document.cookie. However, as there is a common whim for everything, if you are the person setting this…
-
5
votes3
answers1119
viewsA: PHP is not displaying array output
You have two problems and not just one. The first and most important is the fact that you are seeing a white screen because you should be seeing: Fatal error: Cannot use Object of type stdClass as…
-
1
votes2
answers915
viewsA: Two Different Horizontal Menus
The problem was best clarified only in the comments then, although this answer is not in the format of a horizontal menu, it still solves the problem as stated in response of the author himself.…
-
3
votes2
answers800
viewsA: Check if a sequence of numbers corresponds to a valid timestamp
The following response is intended to complement the @gmsantos response. Using the class Datetime PHP as suggested by @gmsantos you achieve your goal. However, for a validation, you have to: Use a…
-
4
votes2
answers1251
viewsA: Form Filters - PHP
In fact, this type of filter is often done right the way you have in mind. But not exactly as you demonstrated in code. First of all, obviously, you must sanitize, filter and suddenly validate the…
-
3
votes2
answers3265
viewsA: Ajax date return behavior
Your technical question has a very, very simple answer. AJAX is a technique to be requested contents a "behind the scenes" address. This content is output that the server sent to the browser in…
-
4
votes3
answers339
viewsA: Why is ':' used in queries?
Although they represent the same thing, parameters and placeholders are distinguished in the way they are presented in a statement. Parameters are nameable, allowing them to be easily identified in…
-
4
votes2
answers1086
viewsA: Possible conflict between script
The following answer aims to extend the initial discussion in the comments of the question. According to the Specification of the W3C: Scripts in the resulting document tree will not be executed,…
-
3
votes2
answers2134
viewsA: Capture data after character # in browser URL
With parse_url() you get this and many other information about a given URL: <?php $url = 'http://urldosite.u/home#6'; print '<pre>'; print_r( parse_url( $url ) ); That little fragment would…
-
4
votes2
answers1328
viewsA: Export php data to xls from a link
In a free translation of the words of John Culviner, creator of the plugin jQuery File Download: Javascript, by design, does not have the ability to perform low-level tasks on its users' computer…
-
3
votes3
answers112
viewsA: Doubt about === and !=
When you use the operator === (or its counterparty !==) you are telling the program to compare the left side with the right not only in value but also in type. Very didactically if you have two…
phpanswered Bruno Augusto 8,661 -
2
votes2
answers1726
viewsA: Average a group of results
Only evidencing my comment earlier in a reply as such. There are two points that need to be checked to achieve your goal. The first and most important is to use jQuery.val() because you want to take…
-
3
votes1
answer1861
viewsA: Google Charts Tools - How to change colors of labels
Since you only posted an image of the graphic I will be taking into account the example code of Google Charts Playground having only the horizontal axis values similar to the one proposed (S1,…
google-chartsanswered Bruno Augusto 8,661 -
2
votes1
answer264
viewsA: preg_replace for preg_replace_callback
Perhaps you were confused as to the purpose of preg_replace_callback(). preg_replace_callback() mainly serves to perform complex regular replacements in a more maintainable way and compatible with…
phpanswered Bruno Augusto 8,661 -
9
votes3
answers864
viewsA: What happens in detail in the destruction of a variable?
TL;DR When using unset() PHP decrees an internal counter of its basic structure for storing composite types called zval. When this counter reaches zero, the memory used is automatically released. To…
phpanswered Bruno Augusto 8,661 -
4
votes3
answers7017
viewsA: What is an abstraction?
TL;DR What is Abstraction? Abstraction is the act of summarizing characteristics or similar actions shared between two or more objects. Why is it important? Because when done well it reinforces the…
-
4
votes2
answers366
viewsA: What happens to class name resolution in php 5.5?
Finally an official response... in terms. It was given to me by someone identified by [email protected] from of this bug that I myself reported. It’s just the caveat that I don’t know exactly how…
-
4
votes5
answers4257
viewsA: Row size Too large (> 8126)
The possible answers to your question are quite complex and technical because they vary by themselves file format Innodb. Nowadays there are two formats called Antelope and Barracuda. The central…
-
18
votes2
answers3311
viewsA: What is the difference between multi-layer and multi-tier applications?
Layers vs. Tiers People normally exchange the two terms to describe the same architecture as multi-layered and multi-tiered simultaneously. That’s not exactly true. Adapting the distinction made by…
software-architectureanswered Bruno Augusto 8,661 -
5
votes1
answer450
viewsA: How should I organize my controllers using the SOLID methodology?
There is a very subtle difference in the One Responsibility Principle that causes this kind of questioning. Having Sole Responsibility is not restrict the object to do a single thing and yes prevent…
-
0
votes2
answers112
viewsA: How to add offset in array for newsletter sending?
One thing you should keep in mind is that, in terms of performance, arrays are malignant. You should never have very large arrays. In the scenario of your problem, the thing is worse because it is…
phpanswered Bruno Augusto 8,661 -
8
votes5
answers22797
viewsA: How to invert dates in PHP, regardless of format?
A very elegant solution, in my opinion, created by a fellow Member of the European Parliament revolves around of the solution proposed by Harry Potter just above (or below :p): /** * Altera uma data…
-
7
votes6
answers14461
viewsA: Convert month number to name
Although there is already an answer, it is the caveat that regarding the location, the class Datetime is extended and does not pay attention to what has been defined, and it is necessary to use…
-
1
votes2
answers3352
viewsA: Return the values of an array after a given key
What if I told you that you can filter this matrix, without injecting it, at least not in the conventional way? Nothing against the solution presented but should be avoided at all costs nested…
-
2
votes3
answers480
viewsA: Check whether $_GET value is 1 or 2 and run SQL UPDATE
Let’s go in pieces... Use preg_match() for this type of simple check is the same as killing an ant with a cannonball. With a little more programming logic, basic that any programmer should have,…
-
1
votes1
answer252
viewsA: Header PDF by Javascript/jQuery
To syntax to send a request header with jQuery would be: $.ajax({ url: "/path/to/file.ext", beforeSend: function( xhr ) { xhr.setRequestHeader( 'Content-type', 'application/pdf' ); } }).done(…
-
2
votes1
answer1636
viewsA: Send files and inputs with the same Ajax request
Think of this application as a template and see which one makes the most sense: A registered user with no uploaded file or a uploaded file not associated with any registered user? If you can see a…
-
4
votes2
answers1172
viewsA: Block unwanted AJAX calls
No system is foolproof. Point! What you can do is add sequential layers of protection. Check how the request was made You yourself have already researched and found how to do it, but the way you did…
-
2
votes1
answer47
viewsA: Maxrequestlen error while uploading files
The directive Fcgidmaxrequestlen defines the maximum length of a Request body. According to the documentation of the module this directive has as default 131072 bytes and that before version 2.3.6…
-
0
votes2
answers513
viewsA: Create jquery navigation menu load method
Most likely you are having the problem you described by the fact that you have invoked a method of event through a response argument, which is always a string. See working in the Fiddle The argument…
-
3
votes4
answers4583
viewsA: Check for image return via Javascript
Another solution coming soen based on an article that today no longer exists (link from the Archives). // First a couple helper functions function $(id) { return !id || id.nodeType === 1 ? id :…
-
3
votes1
answer664
viewsA: How to know if a file has been viewed
Controlling the exact moment the client opens a PDF I find impossible or at least so invasive that should even be considered. What you could do would be to exchange the file and its…
-
26
votes3
answers4535
viewsA: Why shouldn’t we use Singleton?
Singletons are compulsive liars Well, you’ve just joined a new project, which already has a mature and very extensive base code. Your new boss asks you to implement a new feature and, as a good…
-
102
votes8
answers75484
viewsA: Error - "Cannot Modify header information - headers already sent"
This error must be the most asked in the history of the Internet. This answer is a more complete and explanatory translation of another originally posted in Stackoverflow in English made by a…
-
0
votes4
answers175
viewsA: Problem assigning HTML with . text() and . html()
I confess that I had to read three times to try to understand what you have in mind and, from what I could abstract you should use jQuery.html() instead of jQuery.text(), for evaluation of the value…
-
0
votes5
answers9733
viewsA: How to get the index of a javascript object searching for the value?
Another possibility would be with (one more) solution proposed by the PHPJS based on array_search() of PHP: function array_search(needle, haystack, argStrict) { // discuss at:…
-
3
votes3
answers1247
viewsA: Is there a payment gateway that accepts mobile credits?
You’ve probably missed the correct term for a search: Mobile Payment Gateway. Here in Brazil does not seem to be a very widespread medium, but abroad, mainly for games, is often the only solution…
integrationanswered Bruno Augusto 8,661