Posts by Bruno Augusto • 8,661 points
187 posts
-
0
votes2
answers15219
viewsA: Grab the file extension
Since your $_FILES is empty, here’s a Checklist for upload of files with PHP On the server: Check in your php.ini whether the following Directives have these values: file_uploads = On post_max_size…
-
5
votes2
answers1078
viewsA: Render subtitles in video with ffmpeg?
As you yourself could see in the video information the caption is encoded in the second data track, including, this can be played normally by the players that support it, even if perhaps it is…
-
4
votes1
answer142
viewsQ: PHP functions adapted to Mysql
When trying to optimize some darlings not to depend on PHP to do something that could come ready from the database, I was trying to adapt the two routines below in the form of functions mysql:…
-
0
votes3
answers235
viewsA: how to treat different index/templates for the same site?
Just so that the answer has the visibility deserved, I will reset the solution given in comment. If I understand correctly, when doing include/require, you query the value stored in the database,…
-
1
votes2
answers77
viewsA: Print array in a file
The original problem of the topic, having only one row of the table being inserted, occurs because in this part of the code: for( $i=1; $i <= $nombreid; $i++ ) { // ... $list = $affiche; <-- }…
phpanswered Bruno Augusto 8,661 -
2
votes1
answer284
viewsA: Search the database and compare
The problem is with the cast dumb and nosy PHP. According to the manual (free translation): If you compare a number with a string or the comparison consists of numerical strings, then each string…
phpanswered Bruno Augusto 8,661 -
4
votes1
answer700
viewsA: Mysql returning null improperly - MYSQLI PHP
Once again the great villains of history are the charset and the "achism" of PHP. json_encode() accepts strings only when encoded in UTF-8. If you encounter any during the coding process, PHP will…
-
13
votes2
answers450
viewsA: Getters and Setters can only "walk" together?
In Object Orientation getters and setters participate in the Principle of Withholding Information, which ensures that a property is available for reading or writing only in certain circumstances:…
-
2
votes2
answers131
viewsA: Capture and filter result
I confess that if it were not the example of how the string should look after captured and cleaned would have been almost impossible to answer. And these "placeholders" [....] made it even more…
phpanswered Bruno Augusto 8,661 -
0
votes3
answers3898
viewsA: How to 'break' a text at each character range - Javascript
I’ll leave as a contribution port of function str_split() PHP for Javascript by the PHPJS.org function str_split(string, split_length) { // discuss at: http://phpjs.org/functions/str_split/ //…
-
1
votes2
answers197
viewsA: How to set an element via jQuery/Javascript?
Not that it’s really necessary but since we were asked to solve the problem with pure Javascript or also with jQuery and I will be right-footed and leave the alternative here too $( document…
-
4
votes4
answers6464
viewsA: Insertion of a dot every 5 characters
Since they raised the hare on multibyte, I’ll leave an alternative with such support: $string = 'aaaaabbbbbcccccdddddeeeee1111122222maçãsefeijões'; $new = implode( '.', preg_split( '/(.{5})/us',…
phpanswered Bruno Augusto 8,661 -
0
votes1
answer1958
viewsA: Receive input value and pass the URL
And away we go... (Broomstick Witch, Woodpecker) $_GET and $_POST are two superglobal arrays that are always available independent of scope, that is, they will be available in and out of class…
phpanswered Bruno Augusto 8,661 -
0
votes2
answers194
viewsA: Enhanced truncation of strings
Well, I took the case pro Soen and I got a fantastic answer that not only solves the problem but, at my request, solves it in a balanced way. That is, besides interpolating a configurable string…
-
2
votes4
answers798
viewsA: Filter <td> with PHP
I think with ER, if possible, it would be more complicated or less readable. But it’s easy, assuming that this HTML is in a string, and as an alternative to the @abfurlan solution in case the tags…
-
1
votes2
answers194
viewsQ: Enhanced truncation of strings
I was going over some old codes when I found a function that "truncates" a given string after X characters: This function, unlike a replace() simple, does not leave the developer in awkward…
-
2
votes1
answer712
viewsA: Wordpress version compatible with PHP 5.2.17
According to the History of Launches available in Codex the version that fixed PHP 5.2.4 as the minimum required version was 3.1 (Gershwin) released in 2011. So, by deduction, version 3.0 is…
-
2
votes2
answers841
viewsA: What is the practical applicability of the super word in Ruby?
Redefining, overwriting and super Redefining Methods Redefining one method consists of replacing one method with another. And the original method is simply lost. Example: class Rectangle def…
rubyanswered Bruno Augusto 8,661 -
3
votes2
answers201
viewsA: URL rewriting in . htaccess
This will be an express response ^_^ Your URL does not start with Assets-test, then take off that circumflex that the expression happens to marry only backwards and then it will work: RewriteEngine…
-
5
votes5
answers24461
viewsA: Using jQuery Validation Engine and CPF validation
CPF validation occurs through the implementation of an algorithm. With Ers it may even be possible through the modern metacharacter (?{code}), but I find it quite unlikely in addition to plastering…
-
8
votes1
answer662
viewsQ: HMVC and HTML Componentization
I have read several articles on HMVC, both in PHP and in other languages, and in all of them the implementation of the standard revolved around having a "Master Controller" which requested the…
-
9
votes2
answers167
viewsA: Problem with the magic method __call
Your problem, if I understand correctly, boils down to not understanding exactly how the magic __call() method works and therefore have created a logic that would never work as expected. See what…
-
11
votes1
answer736
viewsA: PHP using $_GET
I’ll try to explain: if ($_GET) Supposedly, checks if something was passed along with the URL. This test is unnecessary because $_GET is a superglobal array and I believe it is always present,…
-
2
votes4
answers38774
viewsQ: Sequential numbering of query results
I’m not really close to the database, and actually I don’t even need such functionality, but just out of curiosity, it’s possible to create in Runtime, that is, during SELECT, a sequential numbering…
-
2
votes2
answers1940
viewsA: Pass value via $_GET in include_once
The problem is that querystrings are key=value pairs and the values of each key are all characters between the equal sign and the multiple argument connector (&), if there is more than one, or…
-
20
votes3
answers3152
viewsA: When to use Setters and Getters?
The visibility of a property (public, private and protected) are part of the Concept of Withholding Information, which is important to achieve greater data consistency. For example, the code below:…
-
0
votes0
answers139
viewsQ: Event Listeners and Direct Manipulation of Event Propagation
My recent forays into PHP development were with respect to Event Handling and Event Listening. Through a Mediator it was possible to create a concise and elegant platform to elevate extensibility to…
-
1
votes2
answers872
viewsA: I need help creating two tables with PHP decision structure
Although this is an exercise in logic which, up to the present moment, apparently had no effort on the part of the author demonstrated, I would like to leave my contribution anyway. The solution is…
phpanswered Bruno Augusto 8,661 -
3
votes3
answers1471
viewsA: How do I use a constant within a class method?
Constants, in addition to immutable are global, that is, as long as the resource that depends on it is executed after its definition and is available (see below), just call for it. However, the most…
-
5
votes3
answers641
viewsA: How to connect to Mysql only once, without having to instantiate every time?
There are two possibilities to solve this problem, one of them being less appropriate from the point of view of Object Orientation but perhaps more usable for your particular case. The properties of…
-
21
votes1
answer7882
viewsA: What are . phtml files and when should I use them?
Usually there is no difference from one file type to another when it comes to rendering the page. It is another commodity for programmers when project grows Normally: PHP files. does not contain…
-
1
votes2
answers1432
viewsA: Distribute <li> list in 3 columns
Apparently, just remove the :nth-child(odd)of the last selector and wrap the list in a DIV whose width adds the dimensions of all boxes (more borders and paddings of the box-model): div { width:…
-
2
votes1
answer610
viewsA: ERRORLEVEL command with colors?
For commands running on the Linux Terminal the thing seems to be much easier than Windows Prompt. That one snippet withdrawn of that website: echo -e "\e[31mHello World\e[0m" Causes a Hello World to…
-
1
votes3
answers1927
viewsA: PHP: filter_input with REQUEST
This is a fairly old topic, but since this has been brought up again I will leave two possible solutions to the problem. As you well discovered, the functionality of INPUT_REQUEST was not…
-
1
votes0
answers94
viewsQ: Validate namespace definition
PHP variables, if necessary, can be validated with the following Regular Expression: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* But what about the namespaces? I have a certain string, coming from a…
-
2
votes1
answer76
viewsA: Session is recreated automatically, with a field inside
Just so the topic doesn’t go unanswered: If there is an entry in $_SESSION, it is because a session variable was created at some point in the code. If you don’t remember, search all your sources.…
-
2
votes2
answers1053
viewsA: How to transform the first letter of words into a string
Another possibility, created by the PHP.JS staff based on the function ucwords() of PHP: function ucwords(str) { // discuss at: http://phpjs.org/functions/ucwords/ // original by: Jonas Raoni Soares…
javascriptanswered Bruno Augusto 8,661 -
4
votes2
answers220
viewsA: Is there a function to reindexe a multidimensional array?
Your difficulty, as of many, is to understand the hairy syntax of create_function(). Fortunately the creation of anonymous functions was dramatically improved with Closures, but that’s another…
-
3
votes2
answers488
viewsQ: jQuery.preventDefault(), jQuery.stopPropagation() and jquery.Stopimmediatepropagation()... no jQuery!
There is an implementation crossbrowser for the methods jQuery.Event.preventDefault(), jQuery.Event.stopPropagation() and jQuery.Event.stopImmediatePropagation() that does not require jQuery? I have…
-
1
votes2
answers185
viewsA: Loop to repeat the previous keys (3, 32, 321, ...)
I will leave another possibility, more complex and less performative than Márcio’s, but still valid. If you transpose the original matrix will always have an array of two indices, one with the…
-
0
votes3
answers21897
viewsA: Add to html code via jQuery
In addition to fixing the quote problem, you can create the object of an element in Runtime, add the desired class and add it to the other: $( '<p/>' ).text( 'Teste' ).addClass( 'text-success'…
-
1
votes1
answer106
viewsA: Grab link posted on Facebook
According to that answer in SOEN, and also assuming you are using the Facebook API, you can process the input values links returned by Opengraph, accessible from:…
facebookanswered Bruno Augusto 8,661 -
1
votes1
answer2937
viewsA: How to send PHP variables using Ajax
First. a consideration. of that: <?php $album=$_GET['album']; $id=$_GET['ntf']; ?> It should be at least that: $album = ( isset( $_GET['album'] ) ? $_GET['album'] : 0 ); $id = ( isset(…
-
2
votes3
answers494
viewsA: How to "unlock" any text at the time of "echo" and turn each word into a link
And let the games begin! D Another approach: $str = 'recue o código em 4 espaços'; echo implode( ' ', array_map( function( $word ) { return sprintf( '<a href="%1$s">%1$s</a>', $word );…
-
2
votes2
answers117
viewsA: Inheritance or Addiction?
This is a common question to those who start working with Object Orientation. And, to make matters worse, many people try to explain, but it ends up complicating the explanation so much that the…
-
1
votes1
answer11223
viewsA: Blocked cross-origin request
This answer is another great comment to perhaps help the OP and the other user with the same problem. My contacts with Apis over these years have been very few, so it may even be necessary to do…
-
0
votes2
answers89
viewsA: Text comparison
A slightly different approach that allows depend on of similar_text(), providing its use, by removing points and spaces regularly and conditionally. For this approach, the ideal would be to use…
phpanswered Bruno Augusto 8,661 -
2
votes1
answer162
viewsA: getimagesize() does not work on Plesk + Windows
Let’s go in pieces: getimagesize() expects the first argument to be an image file. Reporting the temporary file may be the cause of the problem; 1.1. And this does not mean that the function is the…
-
7
votes4
answers1592
viewsA: How to ask the PDO if the insertion was made or error?
The ideal is to use the PDO’s Object-Oriented model also for errors, taking the Pdoexception fired when any error occurs: try { $stmt = $conn -> prepare( /* ... */ ); try { $stmt -> execute();…
-
1
votes5
answers611
viewsA: How to count items correctly?
I want to suggest a more efficient approach that solves with a single line (good, more than one because of the readability here in the post) the problem using preg_split(): $parts = preg_split(…
phpanswered Bruno Augusto 8,661