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
-
11
votes2
answers4325
viewsPermission denied when moving file with move_upload_file on Linux server
I’m trying to use the move_upload_file to move a file sent by the user to its final destination: $pasta = '../../public_html/admin/helpdesk/ticket/uploads/'; if (!empty($_FILES['img']['name'])) {…
-
11
votes5
answers10236
viewsecho or print, what really is the best option?
I know the differences of echo or print, but in a real PHP project which one is best suited to use? Or simply whatever?
phpasked 11 years, 6 months ago phpricardo 765 -
11
votes1
answer21808
viewsE-mail with PHP attachments
I am sending an email, everything works fine. Now I wanted to add some files as an attachment. I have the following code: $from = $_SESSION['email_cliente']; $email_destino = "[email protected]";…
-
11
votes4
answers913
viewsIs multiple includes bad for performance?
If I use many includes on my page will make it slower or something?
-
11
votes5
answers83787
viewsPassing variables through the URL using friendly URL via GET
I am trying to mess with friendly URL. Before, to pass the variables I used for example: pagina.php?variavel=valordavariavel by clicking on this link I could use a echo and display the variable. I…
-
11
votes3
answers3508
viewsHow to make a site multilingual?
I have a site made in PHP, now I came up with the obligation to make the site multilingual. I need to translate titles, menus and error messages. User added texts do not need to be translated. I’ve…
-
11
votes5
answers29209
viewsReset to input fields after Ubmit with Jquery
By sending input fields values via Jquery to a PHP page I can do the action without "refreshing" the main page but I can’t make input fields "empty" again?!? How to apply "reset" after submission?…
-
11
votes12
answers5446
viewsHow to remove accent in upload with php?
Part of the file is working. The problem is that when I send a file with accent. Example: send a file with the name ação-íaaa.jpg it looks like this on the server ação-Ãaaa.jpg. So I wanted to…
-
11
votes6
answers57963
viewsHow to convert UTF-8 characters in PHP
In my web application, I am using a Mysql database that has the table EditableContent. This table has the field content, who’s kind text and has as input format utf8-bin. In the database the…
-
11
votes1
answer28571
viewsEnable . htaccess in Ubuntu
I’m using the Ubuntu system on my PC and my apache doesn’t seem to recognize htaccess, none, because I created one. htaccess to my project only that it does not interpret what is in the content. The…
-
11
votes3
answers9405
viewsHow to convert a Mysql connection to Mysqli?
I decided to listen to some users to make the conversion but I need your help because I have done a lot of research and nothing works. The first file is: <?php…
-
11
votes2
answers992
viewsVoice link between two points
I would like to study about, read how it is done and all possible details about making voice calls between two points A and B Similar works these links between users like Viber, Whatsapp, facebook…
-
11
votes1
answer10368
viewsHow to use facebook API?
I have a PHP application, in which I need to log into Facebook and count the number of Ikes in a given post or page. I would like to know how to incorporate this into my application. I’ve heard that…
-
11
votes1
answer2038
viewsPlace text side by side
I don’t know if it’s possible, but I wonder if I can put a text divided into two columns?
-
11
votes3
answers505
viewsWhat are the native exceptions of PHP?
Where it is possible to check all exceptions (native) that can be released by PHP? I searched and only found ways to treat with try/catch.
-
11
votes4
answers781
viewsHTML/PHP Detect if form value has been changed
I have a form where I can change things like username, password, morada, etc. On the site I also use a session (login) for each user, which is defined by username. The problem is that by changing…
-
11
votes2
answers262
viewsHow to parse syntactically malformed HTML?
As part of a procedure, I need to extract the contents of a table present on a page. I’m using Curl to get the raw HTML data and the Simple HTML DOM Parser to parse and process HTML. <?php //…
-
11
votes1
answer58531
viewsRemove accents from a php string
I’m having problems with the accents in my code and I wanted to remove the accents when they did the research, Ex: Search: Hello | Hello. When doing a Music search on the site it returns the url…
-
11
votes2
answers1824
viewsIs there a difference between strtr and str_replace?
I was analyzing the way functions behave strtr and str_replace And I noticed that, at first glance, they both seem to do exactly the same thing. Example: $translators = [ 'da hora' => 'bacana',…
-
11
votes2
answers437
viewsIs declaring a class named after a reserved word a good idea?
Generally, when we define names for class and functions, there is a concern when colliding with the palavras-chaves of language. The curious thing is that I noticed that in PHP it is allowed to…
-
11
votes2
answers791
viewsWhat are the advantages and disadvantages of declaring constants as an array?
I found way too this new Feature of PHP 5.6. It is now possible to define a array for the value of a constant. Look how cool: const BR_DATES = [ 1 => 'Janeiro', 2 => 'Fevereiro', 3 =>…
-
11
votes1
answer3443
viewsUser-friendly URL using HTACCESS
I have the following link: dominio.com/?p=filmes_v&m=tt081692 Man .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^film/?$ index.php?p=filmes [NC,L] RewriteRule…
-
11
votes1
answer1604
viewsHow to concatenate an SQL command into a Mysql Stored Procedure?
In the following show, we have an example already running in PHP. The scenario of the question is the assembly of a "navigation link" based on a data structure. $node = '006002009'; // Esta…
-
11
votes4
answers1541
viewsWhat is the difference between "++$variable" for "$variable++"?
What’s the difference between ++$variavel for $variavel++? I realize that when I execute a for with both forms, the results are the same. Example 1: for ($i = 0; $i < 3; $i++) echo $i; Prints: 0…
-
11
votes3
answers887
viewsHow to print a constant in the middle of a string, without concatenating?
Is there any way to print a constant in the middle of a string, without using concatenation, as with PHP variables? Example: $nome = 'wallace'; echo "Meu nome é {$nome}"; In the case of constants, I…
-
11
votes2
answers496
viewsWhat exactly is hypertext?
I searched and couldn’t find an answer on this: CSS is considered hypertext? I have this doubt because PHP, which is hypertext preprocessor, can also pre-process CSS and even JS.
-
11
votes2
answers19595
viewsHow to use a variable contained in another PHP page?
Hey, guys, good afternoon. How do I use a variable from an X.php file on the Y.php page ? I want to do the following for example: <?php $Frase = "minha frase"; ?> On my Y page I want to get…
-
11
votes7
answers811
viewsHow to write variables in PHP?
I was watching the videos of Robson V.Leite and I realized that at a given moment he retrieves information from the forms to enter into the database in a different way than I use, the only way I…
-
11
votes1
answer310
viewsHow to make a counter with zero left
I need to print values like this, with zeros on the left 00001 00002 00003 for($i = 00001; $i < 10000; $i++){ validar($i); echo $i."\n\r"; }…
-
11
votes1
answer28766
viewsList files from a PHP folder / directory of certain extensions
I need to list the files of a folder, and display them by name linked to his directory for download. I use that code: $pasta = 'uploads/'; $arquivos = glob("$pasta{*.jpg,*.JPG,*.png,*.gif,*.bmp}",…
-
11
votes3
answers2360
viewsVoice recognition in php
This question is of curiosity indeed, I am not touching anything of the type, but in the future who knows. I wanted to know if there is any type of system or if it is possible to create a system…
-
11
votes1
answer1662
viewsError sending Upload with Ajax
I am trying to send a file via Upload to a certain folder but I am not able to do and not understanding the error being accused by the script, I will try to be as clear as possible in the…
-
11
votes1
answer415
viewsWhy should we use functions that start with mb_?
Sometimes, problems arise in PHP in relation to some string functions, because of the condition of them. An example, is the strlen. $a = strlen('str'); $b = strlen('stré'); var_dump($a, $b); //…
phpasked 10 years ago Wallace Maxters 102,340 -
11
votes3
answers1792
viewsIs it a good idea to declare variables with accents?
I was taking a look at the PHP Handbook on the variables. There I found an excerpt of code that left me with the "foot behind". $täyte = 'mansikka'; // válido; 'ä' é um caracter ASCII (extendido)…
-
11
votes2
answers435
viewsWhat are Exceptions and how should I create and embed them in PHP
I’m creating an MVC system and I want to implement Exceptions in my system. I’ve just never particularly used it. So I wanted to know how to apply the Exceptions, since I saw here in Stackoverflow…
-
11
votes3
answers5016
viewsForm validation in modal using Bootstrap
I have the following question. I have a simple record and I want you to tell me when registering a new record: If the field is empty it shows me the message "Fill in the fields"; If the form field…
-
11
votes2
answers1641
viewsWhen to use and not use AJAX when submitting forms?
If I have a giant form of questions, sending via AJAX is the best way? <form id="formulario" method="POST"> <!--vários Questionarios aqui--> </form> Javascript: $.ajax({ type:…
-
11
votes3
answers1027
views$GLOBALS to store settings?
Hi, last week I asked what was the best way to store and read settings for a website, and I got two answers. Of those two answers, there was a lot of speculation, but none really explained why I…
-
11
votes1
answer323
viewsWhat are build cache structures?
In that question where I wanted to know if I should store settings in a global variable $GLOBALS, I got some very good answers, and there was one that talked about something that I hadn’t even…
-
11
votes1
answer363
viewsCustom global variable
In that question here, I explained that I was afraid to save my settings in the variable $GLOBALS because she turns my settings into global values, then the guy answered me that there was no…
-
11
votes4
answers1313
viewsCapture user-typed input with PHP Shell
How can I redeem input data. Example: > Qual seu nome? ...Usuário digita o seu nome... > Olá, $nome-digitado How can I do that Shell Script in PHP.…
-
11
votes2
answers44856
viewsHow to get ip from a user using php?
I’m using the function getenv("REMOTE_ADDR"), to catch the ip users who enter a particular page of my site and then I made a if to redirect that ip which is not equal to the variable of ip allowed.…
-
11
votes3
answers2099
viewsIs it safe and feasible to minify PHP files?
I was left with this question after reading an answer of this question on HTML. I have only minified with PHP, only with HTML, with PHP and HTML... and I didn’t notice any problems... Can it become…
-
11
votes2
answers1673
viewsWhat is the purpose of : (two points) in PHP?
I have this question that is leaving me with a flea behind my ear. I don’t understand at all. What does the sign of : two points. Someone can explain me? Example: if ( have_posts() ) : while (…
-
11
votes1
answer413
views"Referer" or "Referrer"? Is that a spelling error or is that correct?
Honestly, I’m in tremendous doubt right now. I just gave that answer here at stackoverflow: /a/123445/4995 In this answer, I teach that, to refer to the previous page, we should use the variable…
-
11
votes2
answers2954
viewsWhat is a scalar variable?
I was reading the PHP documentation and a function is_scalar() - as stated by the site itself - when it is used it will inform if a certain variable is scalar. However I wanted to know a little more…
-
11
votes1
answer1156
viewsDifference between Pipes, Fork and Threads
From of that question, I was curious to learn more about the subject, so researching further, I came across more doubt on the subject. Because I saw that there is a string of ways to use Threads. We…
-
11
votes2
answers365
viewsHow can I force refresh after deploy?
I have a web application made in PHP, and I wanted to force that whenever I deploy a new version of the application the client is "obliged" to update everything that has changed, such as images,…
-
11
votes1
answer2240
viewsWhat is the purpose of the "assert()" function and when should we use it?
According to the PHP manual assert - Check whether a statement is FALSE Or assert() checks the informed assertion and takes appropriate action if its result is FALSE. And there’s this example of…
-
11
votes1
answer1523
viewsWhat is the purpose of the "use" command and what is its relation to anonymous functions?
I am doing some tests with a Restful API that I am creating using the Slim micro-framework, and in one of these routines that is responsible for executing a certain action caught my attention a…