Most voted "php" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the PHP programming language. For example: questions about classes, methods, functions, syntax and general use of this language. Do not use this tag if PHP is used circumstantially, but has no relation to the question problem. For example: do not use this tag for questions about HTML formatting, CSS or Javascript code.
Learn more…27,244 questions
Sort by count of
-
19
votes2
answers3841
viewsBest practices for sending emails and avoiding spam
Nowadays, almost every web site or web system almost inevitably needs functionalities with sending emails, whether in contact forms, password recovery, account activation, order confirmation, etc.…
-
19
votes6
answers2856
viewsCan not use "{ }" IF keys in PHP cause problems?
Usually for checks that modify only one line I have avoided the use of keys, because PHP accepts this method, but I rarely see codes from other programmers like this... Examples My method…
-
19
votes4
answers955
viewsHow does Current function work?
For some time I always use the function current() in PHP, to get the first element of array (which is actually not its functionality, as it returns the current pointer on which the array is) and…
-
19
votes3
answers1320
viewsWhat are braces {} in an SQL string for?
What are braces for {} in the following SQL string used in PHP for Mysql? $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$placeholders})"
-
19
votes2
answers594
viewsCollect Google Analytics data for Mysql tables
I have seen many examples of how to export data from Google Analytics to other formats as well as keep the exported data updated, but none so far served to export the data to Mysql given the…
-
19
votes3
answers4009
viewsWhy is it important to remove X-Powered-by from response headers? How to remove?
Why it is important to remove the X-Powered-By of the response headers? This prevents some kind of attack, or avoids "insider information" to the attacker? Example: X-Powered-By:…
-
19
votes4
answers10808
viewsIs it possible to create a desktop application using only PHP, HTML, CSS and jQuery?
Although I know that PHP is a language for the web, I would like to know one thing. It is possible in any situation to create an application, system or application with only PHP+HTML+CSS+jQuery that…
-
19
votes7
answers22208
viewsIs using MD5 the safest way to encrypt passwords in PHP?
I know there are several methods of encrypting passwords in PHP (md5, sha1, Base64...) although I don’t know much about, what I see most is the use of MD5. Using MD5 to encrypt passwords is the…
-
19
votes2
answers957
viewsInclude within class and access to $this, self or Static
I found this little code inside the folder Composer/ClassLoader.php, in a project where I use the composer. /** * Scope isolated include. * * Prevents access to $this/self from included files. */…
phpasked 9 years, 7 months ago Wallace Maxters 102,340 -
19
votes5
answers5742
viewsIs it possible to develop websites with C/C++?
I know a little bit of PHP, but I see that on content sites, sometimes it gives a crashes and etc. Researching, I saw reports (very superficial) that it is possible to develop web applications with…
-
18
votes2
answers9606
viewsHow to compile a PHP file?
Is there any way to transform PHP file into bytecode or something similar, and then execute it natively? I need some files on one system to be pre-compiled because of performance in some cases, and…
-
18
votes2
answers23417
viewsHow to select an option in one <select> and load related data in another?
I would like to select an option of a <select> and fill in the other <select> with related content. I will only be able to do this with the information stored in the database or has how…
-
18
votes5
answers22797
viewsHow to invert dates in PHP, regardless of format?
How to invert dates in PHP? I need to invert dates in PHP regardless of the input format, be YYYY-mm-dd or dd/mm/YYYYY.
-
18
votes3
answers6637
viewsRun PHP function asynchronously
Using PHP, it is possible to run a function asynchronously? Example: The client(browser) makes a request to the server, in this request PHP executes an asynchronous function that may take a few…
-
18
votes1
answer2413
viewsHow to generate a pdf file containing the digital certificate information?
I have a PHP system that generates a pdf, and I need to use the client’s Digital Certificate to sign this document. I’ve been reading documents, and I saw that the FPDF that I use does not yet…
-
18
votes8
answers2700
viewsIs it good practice to mix Php and Html?
I see that in python, has the Bottle for example that does the same thing of what I intend to do then... I am new to web practices, student indeed and would like to know if I can use php and html in…
-
18
votes4
answers12892
viewsHow to convert float number to spellnumber in PHP?
Is there any native function, or other practical way, to get a number on float and convert to full number? Example: //input: 2.000,00 //output: dois mil…
-
18
votes2
answers445
viewsIs it wrong for me to use a static method to retouch a collection of objects?
First of all, I know that I should not go out making classes with various static methods but in this case that I bring here, I do not understand why it can be considered bad practice. Let’s say I…
-
17
votes4
answers3280
viewsInteger with 0 to the left is printed as another number
I have this code: $mob_numbers= array(02345674, 12345675, 22345676, 32345677); echo ($mob_numbers[0]); I wanted to print out the first element of array but the output that is: 641980 Why does that…
-
17
votes3
answers9289
viewsHow to change the title of each PHP page dynamically?
I know almost nothing about PHP. Once a friend sent me a code that allowed me to separate my page into several parts and then pick up those parts again in case I change something in the scripts and…
-
17
votes3
answers104158
viewsHow to solve a Notice: Undefined index?
Starting in PHP and following a tutorial I used the above code and ended up getting this error: Notice: Undefined index: Submit in C: wamp www mezzo-com reservas.php on line 3 How to solve it?…
-
17
votes2
answers3105
viewsWhat is the question mark in a query?
Use ? in a query really avoids the SQL Injection? Avoids 100%? I saw this code and I heard many people talking about it, saying it helps in this case and how to use it? Could someone give a better…
-
17
votes3
answers7027
viewsMatch php variable to javascript variable
I’m trying to do something like this: <script type="text/javascript"> function guardar_alteracoes(){ <?php $nome = ?>$('#nome').val();<?php; ?> } </script> That is, I want to…
-
17
votes1
answer4912
viewsSafely remember user
That question does not refer to password security, or data encryption itself. The question is more logical. I would like to know what’s the safest way to create that scheme "remind me". I was…
-
17
votes2
answers13586
viewsUse of $_REQUEST instead of $_GET, $_POST and $_COOKIE
In PHP we have available the global variable $_REQUEST which can be used instead of using the global variables individually $_GET, $_POST and $_COOKIE. For example: <?php // utilizar $bubu =…
-
17
votes1
answer659
viewsWhat is the function of '@' (arroba) at the beginning of PHP expressions
What is the function of @ at the beginning of PHP expressions? I have seen in some classes and could not get the function to put this @ at first.
-
17
votes4
answers847
viewsHow to generate indented code?
How to print indented code when I give one echo by PHP? let’s say the structure is like this: echo '<div>'. '<table>'. '<tr>'. '<td>'. '</td>'. '</tr>'.…
-
17
votes6
answers8335
viewsHow to know if the form is sent
How to know when the form is sent and without input fields being empty? I was told the isset to carry out this action but I did not understand right the use of the isset…
phpasked 9 years, 5 months ago FRNathan13 2,183 -
17
votes1
answer2146
viewsWhat is a chain of methods?
In object-oriented languages, there is a concept known as method chaining or encadeamento de métodos to Portuguese. What exactly is this ? How would be the implementation of this technique in a PHP…
-
17
votes4
answers1239
viewsFormat city names and ignore words like "do", "dos", "das", "da", etc
I’m working with Webservice whose city names are all out of shape and I’d like to create a function to treat the names evenly. An example is this: CHICKEN HARBOR I’d like to keep it that way: Porto…
-
17
votes1
answer1667
viewsWhat is the goal of implementing a magic __invoke method in a class?
I know what the method is for __invoke. It is for a class to execute an action if called as a function. Even, it is present in the special php class called Closure, which is instantiated when we…
phpasked 9 years, 1 month ago Wallace Maxters 102,340 -
17
votes2
answers218
viewsWhat is this !! operator in PHP?
I was analyzing a code in PHP and came across the following: $result = !! $row; return $result; What is this !! and what he does?
-
16
votes3
answers5592
viewsWhere to create a class of its own, and how to instantiate it later?
I have a class of my own (i.e. external to the standard PHP and Laravel libraries) that makes some connections with equipment in my network and also need to create routines for email and SMS…
-
16
votes4
answers3235
viewsIs there a Website/API to host photos on the web?
I wonder if there is any API that makes it possible to host photos on the web. Example: cloud.push(arquivo, callback, fail); I will use this API for the purpose of enabling users to host images for…
-
16
votes2
answers1842
viewsWhat is the Unicode (BOM) signature?
I noticed that sometimes Dreamweaver puts assinatura unicode (BOM) on some php’s pages, I have to remove most of the time so that there is no spacing on the display page and I’m not sure what it’s…
-
16
votes1
answer2380
viewsXSS attacks, how does it happen?
Recently a client was the victim of XSS attacks. We handle all the faulty inputs, but I can’t understand how malicious javascript code was inserted into the files ". js" on the server. How they…
-
16
votes2
answers713
viewsHow to simplify the following IF in PHP?
I had to do a check to concatenate content to a variable, but I think the service got a bit "pig" and wanted to see if someone could help me simplify this check if($IdUserOnline2){ $IdsInteracoes .=…
-
16
votes3
answers864
viewsWhat happens in detail in the destruction of a variable?
I wonder what really happens behind the command unset in a variable in the PHP. I believe this happens in memory, but I would like to deepen my knowledge of this and get the certainty of what…
phpasked 10 years, 8 months ago Rogers Corrêa 2,596 -
16
votes2
answers1907
viewsHow to work with websockets
I’m trying to use Websockets in PHP and Javascript and I’m confused, it uses the protocol Ws:// and wss:// and the server (hostgator) does not have these protocols enabled (I think!) and I can’t get…
-
16
votes5
answers7129
viewsNumber of weeks in a month
I would like to know how to calculate the number of weeks you have a month D S T Q Q S S 1 => Semana 1 2 3 4 5 6 7 8 => Semana 2 9 10 11 12 13 14 15 => Semana 3 16 17 18 19 20 21 22 =>…
-
16
votes2
answers13578
viewsMysql error "expects Parameter 1 to be Resource, Boolean Given in"
$query = "Select * from servico where ID_SERVICO = $id"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $nome = $row['NOME']; if($nome == 'Marketing') { include…
-
16
votes3
answers3152
viewsWhen to use Setters and Getters?
I’m studying OOP and in the encapsulation part I had a question about when to use getters and setters, besides being able to validate the parameter passed, what is the usefulness of using? I could…
-
16
votes2
answers1760
viewsWhat is the difference between "!=" and "<>" in PHP? What to use?
What’s the difference between != and <>? Which one should I wear?
-
16
votes3
answers2621
viewsWhat is end-to-end encryption
I hear a lot about this cryptography business end-to-end but I can’t quite understand why it’s called the "safest option for privacy". I have doubts and enumerated them, see: What is? How it works?…
-
16
votes4
answers8313
viewsIs using addslashes against SQL injection safe?
Use the addslashes() is it really safe against SQL injection? If not, tell me why. I’ll wear mine like this addslashes() <?php $id = addslashes ( $_GET ["id"] ) ; /* Adicionei as barras */ echo…
-
16
votes2
answers450
viewsGetters and Setters can only "walk" together?
I am studying object orientation and am having some doubts in the encapsulation part. For example: Class Url { private $url; public function setUrl($url) { if (filter_var($url, FILTER_VALIDATE_URL))…
-
16
votes2
answers7005
viewsWhat are the differences between die, Exit and __halt_compiler?
What are the main differences between die, exit and __halt_compiler?
-
16
votes2
answers669
viewsWhat are the advantages of using associative arrays?
I came across the definition of associative arrays which are vectors with indices consisting of strings, example: $site['nome'] = "Stack Overflow"; What are the advantages of using this type of…
-
16
votes3
answers1114
viewsWorking with lists without using Array() in PHP
I know that in PHP for almost every kind of list, we work with Array(), but this would be the only way to work with PHP lists? Is there any other way to work with PHP object lists, like the…
-
16
votes4
answers3142
views