Posts by Daniel Omine • 19,666 points
581 posts
-
4
votes5
answers13505
viewsA: Difference between Object and Instance
The instance is an object and the object is an instance? Then would the same thing? Yes and no. On the Wikipedia page itself there are 3 paragraphs that speak the same thing in different ways. It is…
-
1
votes1
answer1225
viewsA: Width of <option> inside <select>
Browsers do not provide support for formatting such as line breaks, for example, in the element <option>. To solve this there are several alternatives and tricks. Limit the size of the text.…
-
1
votes1
answer154
viewsA: Problem to open file
The file path is in the index tmp_name. The index name returns only the original file name. Just exchange name for tmp_name in that passage: $arquivo = fopen($_FILES['arquivo']['tmp_name'], "r");…
-
2
votes1
answer2467
viewsA: How to compress files and directories in php
The function below is a little old but works well. The description of what the script does is in the code comments. function Compress($source_path) { // Normaliza o caminho do diretório a ser…
-
0
votes2
answers66
viewsA: How to change the delimiter of the Php array obtained via POST by replacing the comma?
If the data is already in this pattern 2,7 cm, 3,1 cm and you’re sure that this pattern will always stay that way, so you could just use , (comma and space) as delimiter, so you wouldn’t need to…
-
3
votes1
answer672
viewsA: PHP does not redirect to another page
The problem is probably that output before the header echo" <script> window.sessionStorage.setItem('valor1', '$qtdQuestoes'); window.sessionStorage.setItem('valor2', '$tipoRespostaComplet');…
phpanswered Daniel Omine 19,666 -
1
votes3
answers2214
viewsA: Crontab Linux run PHP Script at a frequency of less than 1 minute
Cron granularity is 60 seconds, therefore, by "normal" ways it is not possible to accomplish what you want, every 1 second. One solution is to bypass with PHP itself. An idea, which is even adopted…
-
3
votes1
answer68
viewsA: Ecomerce maintenance environment - Prestashop
This is an old question that even in the official Prestashop forum no answer can be found. To apply the commits in the modules you will have to create administrative use policies where several…
-
0
votes3
answers3702
viewsA: Notice : Array to String Conversion in
You are assigning an array type parameter to a function that should receive the string type. A suggestion for correction: <select name="tipoPessoa" class="form-control"> <?php $tipos =…
-
2
votes2
answers676
viewsA: Inc and MVC extension in PHP
File nomenclature is indifferent to MVC or any Patterns design. Including ". inc" and ". class" was an old practice that even many older PHP programmers disagreed with the use. Basically, these…
-
1
votes3
answers3377
viewsA: How to eliminate excess spaces in a string?
Alternative using Perl regular expression // inclui a Perl Compatible Regular Expression #include <pcrecpp.h> char str = "a b c"; str = pcrecpp::RE("!\s+!").Replace(" ", &str);…
-
1
votes1
answer955
viewsA: Name a cell
Via VBA Dim r As Range Set r = Range("E2") r.Name = "ONomeDaCelula" Alternative via Excel Interface Open the context menu of the cell you want to set a name. You can do this by right-clicking: Set…
vbaanswered Daniel Omine 19,666 -
6
votes3
answers1435
viewsA: How do I generate a random negative number?
import java.util.Random; Random rand = new Random(); int n = (rand.nextInt(50) + 1) * -1; The above example is purely didactic. The number 50 defines the range and has been set for demonstration…
-
0
votes4
answers1114
viewsA: How to create multiple folders with mkdir
Set the third parameter of the function with value true. This parameter indicates that non-existent directories will be created recursively. mkdir('foo/bar/folder/', 0777, true); Of course to inform…
phpanswered Daniel Omine 19,666 -
3
votes2
answers98
viewsA: Error in php parse_str function with Special character
That is the scope void parse_str ( string $encoded_string [, array &$result ] ) Therefore, encode the non-ascii characters before passing the function: parse_str(urlencode('c=item1 + item2'));…
phpanswered Daniel Omine 19,666 -
2
votes2
answers727
viewsA: Square root and cube number in a table
You can store them in an array <?php for($i=1; $i<=10; $i++) { $rs['cube'][$i] = pow($i,3); $rs['sqrt'][$i] = sqrt($i); } ?> With this you can manipulate the data as you wish. But it is not…
-
1
votes2
answers672
viewsA: Script bat not run completely
Apparently the path of homeWildfly set homeWildfly=C:\Program Files\Java\wildfly-10.1.0.Final /\ | A chunk of the path contains spacing. To avoid path breaking, delimite between quotes set…
cmdanswered Daniel Omine 19,666 -
8
votes1
answer669
viewsA: Free SSL certificates Let’s Encrypt has the same reliability as paid?
The certificates currently offered on the market are so cheap that, particularly speaking, it does not compensate the "economy" with free alternatives. But regardless, Let’s Encrypt currently has…
-
3
votes2
answers115
viewsA: Because Chr() is vulnerable to "cache-timing" attack and pack() is not?
The implementation of the function pack() is much more robust compared to function chr(). It has several sanitizations and validations, among them, the RFC 4648 Encoding An excerpt from the pack()…
-
3
votes1
answer1048
viewsA: Excel How to find the current cell address
Select the cell where you want to apply the formatting rule and click "Conditional Formatting". Choose, "Manage Rules". Make sure there are no other rules that may conflict. In this example, it’s…
excelanswered Daniel Omine 19,666 -
1
votes1
answer62
viewsA: What is the right way to mount interfaces on PHP pages?
There is nothing wrong with opening and closing tags to compose HTML content. Everything that is delimited by the PHP tag is parsed by the PHP compiler. If you pass things not related to PHP, this…
-
3
votes1
answer271
viewsA: Redirect by href PHP
In the archive User.php, put something like this: class UsuarioDAO(){ public function excluir($id){ //codigo vem aqui echo 'ID para excluir: '.$id; } } /* Verifica o parâmetro recebido pela URL */…
phpanswered Daniel Omine 19,666 -
3
votes1
answer86
viewsA: How to give permissions to all Mysql users at once?
Mysql GRANT command does not accept wildcard for user definition. A simpler option is to set to a specific host and without specifying a user: GRANT ALL PRIVILEGES ON nomedobanco.* TO ''@'localhost'…
mysqlanswered Daniel Omine 19,666 -
3
votes2
answers226
viewsA: Which . NET should I use?
As a developer(a), the least you should know is the target (target) for which the project will be built. Establish yourself(a) the requirements. The most obvious is to provide compatibiliadde for…
-
3
votes2
answers3045
viewsA: Format PT BR date and time return in PHP
The format presented in the question has the following symbols: M d Y H:ia M -> Representação textual do mês, abreviado d -> Dia, 2 dígitos Y -> Ano, 4 dígitos H -> Hora, 2 dígitos i…
-
3
votes1
answer149
viewsA: Is it possible to know the number of lines a text occupies in a <p>?
For such a task you will have to calculate the boundbox of the font family and measure the proportions by scale according to the width of the HTML element. With this you can have a very close and…
phpanswered Daniel Omine 19,666 -
1
votes1
answer424
viewsA: How to change specific contents in the script of a //PHP file
Note that there are several ways to solve. In the example below, I opted for something that was not invasive, modifying the current structure or business model. I just suggest modifying the pattern…
-
4
votes1
answer980
viewsA: meaning of Redim in classical Asp
The builder redim resizes an array at runtime. It is important that you also know the preserve which is used to preserve existing values. redim preserve array() The preserve is not mandatory, but it…
aspanswered Daniel Omine 19,666 -
3
votes3
answers1757
viewsA: Problem creating script . sh to enter a directory
The command cd inside the bash (.sh) runs under a subshell. The action is successfully executed however, the main shell has no effect because it was executed in a different context. A simple trick…
-
12
votes2
answers221
viewsA: Full snippets of commented codes. Why?
In addition to what has already been covered in the existing answer, there are also those code snippets that serve as an example of how to use a certain function. Example: /* Usage sample 1: $rs =…
-
0
votes1
answer58
viewsA: Doubt about include in files in previous directories
The current directory of the first, index.php, is assumed in all other files. Can only use <?php include "functions.php" ?>. However, be aware of the configuration directive include_path. To…
-
1
votes1
answer2784
viewsA: Domain pointing to a port IP?
DNS zones are indifferent to the IP protocol to which the names, aliases, cname, among others. What determines the next port is the client software. A web browser sends requests to port 80 by…
-
2
votes2
answers42
viewsA: Cronjob with cached file
Modify the scheduling processes so that, while searching for new information, instead of deleting the current cache, you generate the new data in a new file. As soon as you complete this new file…
-
2
votes2
answers972
viewsA: Point to a folder before DOCUMENT ROOT?
A simple way is to define a constant for the location you want. define('PRIVATE_BASE', _DIR_.'/../'); With that just call PRIVATE_BASE to mount the path base. Of course this will depend on how the…
-
6
votes4
answers366
viewsA: What’s the difference in using sprintf in relation to using variables within the string?
The function sprintf() format a string based on the order of the parameters defined in the first argument, which makes everything very dynamic, allowing you to format strings very flexibly. An…
phpanswered Daniel Omine 19,666 -
2
votes6
answers1348
viewsA: Is there an alternative to system('cls') in PHP Console?
The codes of all other answers did not work in my environment: Windows 10, PHP7 and earlier versions up to version 5.3.6. Of all the answers found on the internet, the most bizarre is to do dozens…
-
2
votes2
answers354
viewsA: Validate preg_replace domain
Domain names may currently be Unicode (utf8). Depending on the rules of your business model, if you need to allow domains that have non-ASCII characters, the following routine may be useful:…
-
0
votes1
answer77
viewsA: Phonegap can I create an app and market it?
You can market, monetize, distribute free of charge or even as an open source or both combined without having to burden the IDE developer. Q: HOW MUCH DOES PHONEGAP COST? A: Phonegap is an open…
apache-cordovaanswered Daniel Omine 19,666 -
2
votes2
answers142
viewsA: How do you detect three equal numbers?
The question lacks more accurate information to demonstrate a concise solution. But regardless of that, based on what posted: $premio_soma = 0; for ($i = 0; $i<9; $i++) { $n = mt_rand(1, 9);…
phpanswered Daniel Omine 19,666 -
0
votes4
answers8807
viewsA: How to convert a date variable to the Brazilian format within a view?
Apparently by what you describe in the question and comments, the object must be a string. In this case the example below should solve:…
-
1
votes3
answers52
viewsA: Character manipulation in PHP
Option with REGEX $str = 'joao.silvestre'; preg_match('/[^.][\w]{6}/', $str, $rs); echo $str[0].$rs[0]; Time: 0.00000905990600585938 (9μs)
phpanswered Daniel Omine 19,666 -
5
votes2
answers3075
viewsA: How can I see the structure of a table in Sqlite?
Something closer to command DESCRIBE [tabela] mysql: PRAGMA table_info([tabela]); If you want something more detailed: .schema [tabela] You can also get everything by calling only .schema without…
-
-1
votes3
answers324
viewsA: "Translate" query from Mysql to SQL Server 2012
The function NOW() swap for GETDATE() In the question code, the syntax is wrong: REPLACE INTO schedule SET jobname = "sqldump" , last_exec_date = NOW() In Mysql the correct syntax should be REPLACE…
-
0
votes2
answers542
viewsA: XML returning empty in PHP
See own functions of Soap or invoke the method simplexml xpath: To use the xpath method, a simple example: $str = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">…
-
5
votes1
answer148
viewsA: Check if file was created
Simplifying function createFile($path, $nome, $content){ return file_put_contents($path.$nome, $content); } The function file_put_contents() boolean returns false in case of error. Otherwise it will…
phpanswered Daniel Omine 19,666 -
3
votes2
answers86
viewsA: Problem with use in PHP
The operator use serves as an alias for namespaces. There is another purpose of use in which you pass an argument by reference, but it is not the case here so the focus will only refer to what you…
-
3
votes4
answers130
viewsA: How to format this array?
The question is vague because it is not known where the data comes from and where it will be used or if there are other conditions such as a second subscriber ID, for example. For now, I’d kick…
-
4
votes1
answer122
viewsA: Session data in php
Session data stays on the server, no direct access by an unauthorized third party. A possibility to gain access to a particular session is session hijacking, known in English as "Session Hijacking".…
phpanswered Daniel Omine 19,666 -
1
votes1
answer2909
viewsA: Accept payment via Credit Card via PHP with SSL
This requires a payment gateway. No operator or bank provides such service directly to the final consumer. There is always a gateway that is the intermediary. Paypal, for example, offers Direct…
-
2
votes1
answer96
viewsA: Make PHP print names in certain classes
Avascript runs through the user’s browser. PHP runs on the so-called "backend", that is, you need a request to the server where PHP is located. There is no function like in Javascript, able to…
phpanswered Daniel Omine 19,666