Questions tagged as 'php'

2
answers

Why do we have to use it? ? php when we use eval in the contents of a php script?

I took a look at the source code of laravel 3 and saw the following code: eval('?>'.$__contents); On other occasions, I've seen something like: $content = file_get_contents('file.php'); eval('?>' . $content . '<?php'); Why do...
asked by 12.08.2015 / 16:21
2
answers

What can Model do in validation in MVC?

In an MVC project developed in PHP, should I validate what in model and what in controller ? Hash of passwords I'm doing in the set method of the model classes. Some validations that are not returned to the user I believe I should do...
asked by 07.06.2015 / 18:28
2
answers

Why does date_diff count my date range wrong?

In my code: date_default_timezone_set('America/Sao_Paulo'); $DataEntrada = new DateTime('19-10-2014');//data no formato d-m-Y $DataSaida = new DateTime('21-10-2014'); $interval = date_diff($DataSaida, $DataEntrada); $totalDiarias = $interval-...
asked by 10.09.2014 / 20:24
3
answers

How to check if a value is a date

How can I check if a post is of type date ? There has been a situation where I have a form that contains a date field: <form action="" method="post"> <input type="date" name="data"> <input type="submit" name="en...
asked by 19.10.2016 / 18:20
1
answer

Token identical "==" is used only in PHP? Because?

During my studies in C language and Java, I have always come across the sign "=" of assignment and the "==" sign being equality . However, I'm studying PHP now and I came across the sign "===" of identical . My ques...
asked by 27.02.2017 / 16:12
2
answers

Separate values from each array

Good day, people, okay? I have the code that prints the different values found in 2 arrays and those values get stored in the different variable ($ different) I need to know how I can print these values stored in different but telling which arra...
asked by 05.04.2016 / 14:28
1
answer

How to change the version of PHP in which Composer runs on Linux?

I installed the composer on my Ubuntu through the following command: apt-get install composer Ubuntu currently supports multiple versions of PHP installed. I have PHP5.6, PHP7.0 and PHP7.1 installed on my machine. When I only had PHP5.6,...
asked by 16.03.2017 / 16:22
3
answers

How to add more products?

I'm creating a personal "sales" system for my father's company. I just have a problem. I can only sell one product at a time, I'm new to PHP so its not much to do. I want to make a "cart" and can add 2 or more products. I tried the following:...
asked by 26.03.2017 / 22:21
3
answers

Foreach by reference or by value? [closed]

Is there any difference in performance and security between using foreach by reference or by value? I always use the first option (when needed) because I find the code less confusing to read. Reference: Here I change all the values of an a...
asked by 13.10.2016 / 16:36
2
answers

Resize image with PHP while maintaining proportion

I'd like to resize images by proportion from a remote link using PHP. Is this possible? Type:    link for    link Note: In this case, the 2 addresses belong to me. No image theft.     
asked by 19.03.2014 / 02:47