Questions tagged as 'php'

1
answer

How does pointer to function work in PHP?

In C you can use function pointers to reference other functions, see an example: int somar(int a, int b) { return a + b; } int (*sPtr)(int,int); int main(void) { sPtr = &somar; int r = sPtr(10, 5); printf("Soma: %i",...
asked by 17.01.2017 / 17:39
1
answer

Form with a field of type "file" arrives at the server with "$ _POST" empty

On our hosting server, I have two projects, where both have a module in our administrative area to manage images. In the A project, the form is submitted to the server and the $_POST array is received by the server with the image fie...
asked by 09.01.2014 / 16:32
2
answers

Get an inverse relationship with Laravel

I am creating a forum system that is divided by sections. Each section contains categories, each category contains topics. Ex: Administração _ |_Regras da do fórum |_Sugestões e críticas Aeromodelismo _...
asked by 17.02.2014 / 16:35
1
answer

Include tag in the first word of a string

I do not know much about regex, so I got this rule ready. $break_title = preg_replace('/(?<=\>)\b\w*\b|^\w*\b/', '<span>$0</span>', $title); return $break_title; The problem is that it does not recognize the cedilla, so th...
asked by 17.10.2014 / 21:52
1
answer

Zip directory with PHP

I have a code that compresses file and directory. The problem is that it compresses the files and directories that are in the root, but the subdirectories they are not compressed, for example I have these directories:    folder /, folder / fi...
asked by 10.07.2014 / 03:53
1
answer

Structuring the router class in PHP with MVC

A friendly url of the type: www.meusite.com.br/controlador/metodo/argumentos It is handled in my Request class, where it "explodes" the url , separating it into segments, which are $controller , $action and $args...
asked by 21.02.2015 / 04:49
1
answer

What is Service Container?

I was reading about Service Container in Laravel, but I was not able to fully understand the purpose of this feature. I know that to create new services we have to use some Laravel methods: App::bind() or App::instance() there are...
asked by 26.03.2017 / 01:24
2
answers

How to save two variables from a JS in php session?

I wonder if there is a way to save these two variables. Here is the code: <script type="text/javascript"> function opcao() { $(document).ready(function() { var empresa = $('#Empresa op...
asked by 18.05.2016 / 14:30
1
answer

How to execute PHP file from function in JavaScript?

I have the following structure for registering a new MySQL database account (register.php): <?php $con = mysqli_connect("meu_host","meu_user","minha_senha","banco"); mysqli_query($con,"INSERT INTO contas VALUES (" + $id + ", " + $pass...
asked by 25.03.2014 / 04:09
1
answer

Problem with types in function parameter

When you run the following code: function foo(string $text) { echo $text; } foo('bar'); I get the following error:    PHP Catchable fatal error: Argument 1 passed to foo () must be an instance of string, given string, called in / hom...
asked by 24.01.2014 / 01:33