Questions tagged as 'php'

4
answers

Subtraction of hours in php

When I subtract the time the result is "0" I want it to be in the time format, for example: 19:38:20 - 19:37:00 = 00:01:20. Note: The "time" values of the database I'm assigning to "$ time1" and "$ time2" are in varchar format. I have already...
asked by 25.04.2016 / 00:46
5
answers

Remove last comma from an array

In this code below I have an array that returns me a comma at the end  exe: '98602', '98603', '98604', How can I remove this comma? if (isset($_POST['checkbox'])) { foreach ($_POST['checkbox'] as $key => $value) { $id = mysql_re...
asked by 06.03.2015 / 16:09
2
answers

How do I store settings for a site?

I want to develop a site that has some configuration options, for example: Keep the default or custom logo Allow new user registration Authorize anonymous comments on posts How should these settings be maintained? Remember that there...
asked by 01.12.2015 / 15:09
3
answers

How to abbreviate words in PHP?

I have common information such as people's names and addresses, and I need them to contain a maximum of 30 characters without cutting words. Example: 'Avenida Natalino João Brescansin' => 'Av. Natalino J. Brescansin' 'Joaquim Rossafa Nas...
asked by 09.05.2016 / 15:43
2
answers

Is "slash" required at the beginning of native functions when using namespace?

I noticed that some libraries often use native PHP functions as \ , for example: echo \str_replace('foo', 'test', $string); I've been testing inside a class with just this namespace: public function foo($string) { echo \str_re...
asked by 03.08.2015 / 23:13
9
answers

Search via ajax during typing in input text (autocomplete)

I made a search using ajax that when clicking a button triggers a request with the searched term and returns with data that fills combobox html ( select ). So far so good. However, I found it interesting to change this behavi...
asked by 02.01.2017 / 17:39
2
answers

Force declaration of properties

I'm implementing a filtering feature in some classes of my application through traits . The function of trait will use class variables through some properties defined in the class: <?php trait FilterTrait { public f...
asked by 29.08.2014 / 21:55
1
answer

Multiple-step form, losing values of variables when page changes

We have three PHP pages with html form. In the first page we have the fields showing the values of the variables and the hidden fields containing the values of the variables like this: <input name="nome" type="hidden" value=".$nome." >...
asked by 14.03.2014 / 04:17
2
answers

Can I integrate PayPal into my site without the user signing in or creating an account?

I was looking for and reading about it, but what I see most is just put the button to pay with PayPal, which requires that who is buying to log in to Paypal. Can you do this, some example code light? Because I saw that it is possible, but where...
asked by 12.06.2016 / 00:52
1
answer

Select with prepared statements MySQLi

//// The connection is of type MySqli was passed by the constructor method and assigned the variable $ db; public function getById($id) { $query = $this -> db -> prepare("SELECT * FROM tabela WHERE id = ?"); $query -> bin...
asked by 18.10.2015 / 00:44