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
-
16
votes4
answers16259
viewsHow to use Progressbar with Ajax and PHP?
I found some examples where the developer implements a setInterval trying to predict the import time and in the complete ajax put 100% making that bar Progress get "a bit buggy" or jump from nowhere…
-
16
votes4
answers1229
viewsHow do you know if a certain day is a weekend?
How to know if an informed day, of the current month, fell on the weekend? For example: echo isWeekend(24) // True echo isWeekend(26) // False In the related topic below, I can know today through…
-
16
votes4
answers4728
viewsHow to write values to the Mysql database using PHP?
I have a database that I created in MYSQL with the table called publicacoes. This table has the fields id, titulo, conteudo and data_publicacao. I would like to know how to insert values in this…
-
15
votes4
answers6633
viewsHow to make the browser "Back" button work on an AJAX site?
I researched this topic a year ago when I made a site with features like $.load() and $.ajax() in AJAX/jQuery but did not get anything satisfactory that was not overly complex, and until today the…
-
15
votes6
answers90846
viewsDo I use PHP inside an HTML or an HTML inside a PHP?
I made all my site in HTML and CSS, but now I need to use PHP to send some data to a database. I’m just wondering if I modify all my documents to . php or if I use PHP inside HTML (if possible).…
-
15
votes6
answers11947
viewsHow to create a password reset link?
I am developing a site that has user registration area, the password is encrypted to increase security on the site, but when the user forget the password how will it be possible to return his…
-
15
votes5
answers41336
viewsNumber formatting (PHP)
I created a function cotacaoDolar(); who returns at the end: return str_replace(",",".",$texto_dolar); And the result, appears here: echo $i['sellingStatus'][0]['currentPrice'][0]['__value__'] *…
phpasked 10 years, 11 months ago GustavoCave 545 -
15
votes4
answers28026
viewsAccent in mysql select displaying question sign " "
Today I migrated my site to hostgator and happened this problem, the accents are all with some characters The files are all with correct accent in the database My collation in the database is as:…
-
15
votes2
answers7112
viewsHow to translate a website into PHP?
I’m making a simple website with just a few pages PHP. I would like this page to be translatable to portuguese and english. I already use the function gettext in python and saw that in PHP the…
-
15
votes4
answers844
viewsrtrim() to remove "<br>" also removes the letter "r" if it is the last letter in the string
If a string ends with an HTML tag, for example <br> or <hr>, when making use of the PHP function rtrim() to clear said tag, in cases where the letter immediately before is an "r", the…
-
15
votes3
answers1122
viewsIs it possible to manipulate PHP errors via code?
As you all know, PHP returns runtime syntax errors in the browser, such as fatal errors and exceptions. It is possible to handle these errors via code so that I can save to the database in a table…
-
15
votes2
answers2622
viewsWhat to save in a login session?
I am developing a login system in PHP and Mysql for an administration panel, and I have seen many "secure" login systems where they store in the session the user login or password, that is when they…
-
15
votes2
answers500
viewsDoes data received from HTTPS come encrypted?
If I install certificate SSL and use HTTPS on my website, for example, I run a form POST, form data arrives encrypted to the server? If yes, how to decrypt using PHP?.…
-
15
votes3
answers2003
viewsIn PHP the correct is Else if or elseif?
In PHP, the correct is else if or elseif? What’s the difference between them? The language allows writing everything together and separately, and apparently the results are identical…
-
15
votes5
answers667
viewsUse JS to relieve PHP
Well, I have a PHP file that generates a document (I get it by AJAX). This document goes through some functions (which I did in PHP), such as converting a string to code, adding fields.. Well, for…
-
15
votes1
answer2407
viewsHow to update my Mysql code to Mysqli?
I have codes that use mysql and need to upgrade to mysqli. I need to make two changes, being them on the pages .php which insert the data into the database table and also into the pages displaying…
-
15
votes1
answer2041
viewsSQL LIMIT parameterized in PHP with PDO
A few days ago, I stopped using the functions mysql_*(already obsolete), and I switched to PDO. I have a function that does query database, but I’m having some problems using the LIMIT with Prepared…
-
15
votes2
answers716
viewsWhat is the name of => operator in PHP used in arrays?
In PHP, when we declare a array directly, we have the operator =>. I know that in PHP we have the ->, that is Separator Object, but I had to give the name to => and could not explain. What…
-
15
votes8
answers5012
viewsPrinting a String until a space is found
I receive a String through an input and enter it into the database. When I list, I only want the person’s first name, that is, until the first space is found. Is there any function that does this?…
-
15
votes8
answers1094
viewsIs it recommended to use constants for configuring a PHP project?
It is very common to see constants in a configuration file in a PHP project, but I would like to know if this is really the best practice, because I think if I store the password of a database in a…
-
15
votes4
answers4258
viewsHow to prevent direct access to my PHP code?
I have a PHP application and I don’t want the user to be able to type the name of a specific file in the address bar, for example { example.com/send.php }, all my files are called by index.php, as I…
phpasked 9 years, 4 months ago Ana P. Messina 360 -
15
votes2
answers7197
viewsAdvantages of using Object-Oriented PHP? Where to use?
Lately I did a mini social media and practically did not use object orientation, except for one class I did for CRUD with PDO and ready-made Github libraries. Would this concept be applied more to…
-
15
votes2
answers534
viewsCount of black pixels that have been plotted on the web image
I want the user to trace a line in a biometric image and make an automatic count of "black parts" of the digital that this line crossed. I have no idea which tool to use and where to start...…
-
15
votes2
answers5421
viewsHow to validate each data type received from a form?
This subject has several related topics, and generates as many back and forth, each with a different answer. In some cases we have great answers, but no specific question about this question (in the…
-
15
votes2
answers883
viewsWhat is the difference, in practice, between Session and Application?
I’m studying about Tecnologias Web, and during my class there was a topic about concepts involving Session and Application. The technology addressed during the class was C#. I didn’t quite…
-
15
votes2
answers7415
viewsWhy use error_reporting with display_errors and display_startup_errors?
I’ve been using only for a long time: error_reporting(E_ALL|E_STRICT); To debug scripts (note that I use E_STRICT only to maintain compatibility with older versions of PHP), but I noticed that other…
-
15
votes2
answers221
viewsFull snippets of commented codes. Why?
I’m learning PHP and use scripts ready to study them, as a complement. However what I often see is whole snippets of commented code. Does anyone know why? Does it have any function? If the project…
-
15
votes1
answer10056
viewsUpload images with Crop and resize, jQuery and PHP
I need a function in which the person should upload an image, and it should "crop the image", leaving it in the right size, Facebook style and then should be saved in the databank. I tried several…
-
15
votes6
answers2755
viewsIs it bad practice to use only static methods in a class?
I was studying further sinking the OOP, learning more advanced concepts such as Polymorphism, Override, Classes and final methods, abstraction, namespace and etc... I learned about static methods,…
-
15
votes1
answer3432
viewsWhat is the purpose of Middleware in relation to Apis and Web Applications made in Slim?
I’m reading regarding Middleware no framework Slim, however, I could not understand the purpose of Middleware in relation to Rest Apis or Web Applications built in Slim. I was also talking to…
-
14
votes3
answers2493
viewsHow to check if a string has only uppercase letters?
How can I check whether all the characters in a string are capital letters? Preferably without the use of regular expressions.
-
14
votes6
answers1877
viewsCode refactoring to convert GPS coordinates into DMS format into an array
The user can enter GPS coordinates in two ways, Decimal Degrees or Degrees, Minutes, Seconds: ┌─────────────────────────────────┬─────────────────────┐ │ DMS (Degrees, Minutes, Seconds) │ DD…
-
14
votes4
answers6297
viewsForm inserting twice in the bank (F5)
I have a great form that update and insert at various points when submitted. However, if in the time interval of this process the user presses F5, he duplicates the insertion record the number of…
-
14
votes5
answers141242
viewsHow to get the current date and time without using the computer clock?
I’m having trouble in the date, he takes my clock from my computer and I wanted him to actually pick the right time. The result of the following code is that the date will take from your host…
-
14
votes1
answer60239
viewsScript that sends Whatsapp message?
There is the possibility to send a message Whatsapp through a Script PHP? (Like a text or an e-mail) I found a class, but it’s old and no longer works (the servers changed, with the sale of Whatsapp…
-
14
votes6
answers11304
viewsHow to get distance given the coordinates using SQL?
I’m doing a function in php, in which, given a GPS coordinate, it will search in the database the recorded locations, which are not necessarily fixed, within a certain distance. My question is, how…
-
14
votes4
answers1700
viewsUnderstanding Node and Applications in Real-Time
Since I met the Cakephp I got used to programming with him, because I had a small learning curve and very fast development. For my recent application, I needed the data entered by users to be…
-
14
votes2
answers3560
viewsHow to calculate the freight of various products
I am developing a virtual store and I need to implement the freight calculation for the purchase, I managed to make this implementation but the problem is that with a single product in the cart I…
-
14
votes2
answers3471
viewsSearch with LIKE or MATCH.. AGAINST in two columns
I have a classified system where I do a search with PHP and Mysql using LIKE in two camps: campo1 like '' or campo2 like '' The problem is when I’m looking for something like, "Green car" it doesn’t…
-
14
votes1
answer441
viewsWhat is the purpose of Array and String Dereferencing implemented in PHP 5.5?
In the PHP manual, we can see New Features the functionality of Array and String literal Dereferencing. Example: echo 'string'[2]; // r echo ['stack', 'overflow'][1]; //overflow Thinking in case you…
-
14
votes2
answers16859
viewsHow can I get the lottery results?
I searched for lottery API’s to get the results of the contests, unfortunately I could not find any. The response of @fpg1503 can read only the result of the current game, I wonder if it is possible…
-
14
votes3
answers18167
viewsPDO Drivers for SQL Server
I am trying to run a PHP application (version 5.5.8) with connection to SQL Server database with PDO, but returns the following error: could not find driver I’ve tried enabling features in php.ini…
-
14
votes2
answers683
viewsWhat is the Declare keyword in PHP for?
After all, what is the key word for declare in PHP? I’ve seen explanations around, including in Manual for PHP, but still I did not find its functionality very clear. It can be useful for…
phpasked 10 years ago Wallace Maxters 102,340 -
14
votes1
answer137
viewsRFC6530 - Check if variable contains a well formatted PHP email address
Approval adopted by the Gmail as published in Official Gmail Blog, and as defined in RFC 6530: Assuming a function valida_email() that would return boolean: echo valida_email("té[email protected]"); //…
-
14
votes4
answers2074
viewsHow to get the format in hours when it exceeds 24?
I’m developing a PHP system where I need to get the total time of an audio file at some point. This time is saved in the database in seconds and also in the format of hours. The problem is that when…
-
14
votes1
answer2472
viewsWhat is spl_autoloader_register in PHP?
What is the role of the spl_autoloader_register, and in which possible scenarios this function could be included?
-
14
votes3
answers823
viewsCan I have Javascript write PHP?
I can do the javascript write down php? Related: I can write in Javascript inside PHP? I can write ajax and javascript together?…
-
14
votes1
answer2315
viewsReal time with PHP
I am developing a system and soon I will have to start the real-time interaction part (for notifications and chat). I am using jQuery, PHP and MySQL so far and I intend to continue with these…
-
14
votes2
answers4638
viewsFibonacci sequence
I need to perform an exercise to show the Fibonacci sequence up to the 100th element, I need to create a Fibonacci function that should receive the element index and the function will calculate the…
-
14
votes3
answers14607
viewsHow to identify which city the user is in?
On some shopping/service sites an identification or suggestion is made of the city the user is in order to show only the products/services specific to the user’s city. Detail, this will be used only…