Questions tagged as 'php'

1
answer

What is the benefit of using closures in PHP?

Eg: Why use a closure for this function: We could do the same thing without a closure, but why use this class? public function getTotal($tax) { $total = 0.00; $callback = function ($quantity, $product) use ($tax, &$tota...
asked by 09.07.2014 / 21:32
3
answers

Count the columns of a MySQL table using PHP

How can I count the columns of a MySQL table using PHP, does anyone know of any commands to do this? I tried to do this but it did not work: $sql4 = mysql_query("show fields from ".$tabela) or die('erro na query'); $rows4=mysql_fetch_array(...
asked by 26.06.2014 / 14:11
2
answers

Comparing string in php

I would like to know how to compare the contents of a string in PHP. I'm looking for a word on a line, but I do not know what position it is in. $ch_atend if($linha == "idle") { $ch_atend = $ch_atend++; }; This code is within a While and...
asked by 17.06.2014 / 19:08
2
answers

What happens with class name resolution in php 5.5?

PHP 5.5 has implemented a new feature, which consists of getting the class name through the keyword class : Example: namespace testando; class Teste{} echo Teste::class; // testando\Teste; This works correctly, as expected. Now...
asked by 24.06.2014 / 19:37
1
answer

Namespace and PDO = Error

I'm doing a Framework, using namespaces. But in the PDO connection file a strange error is happening to me:    Fatal error: Uncaught exception 'PDOException' with message 'could not   find driver 'in C: \ xampp \ htdocs \ Application \ Core \...
asked by 06.06.2015 / 04:25
1
answer

System hashtags in PHP

I'm developing a hashtags system in PHP , and my question is: How can I make a% of% of posts from content? For example, the content saved in the database is:    Hi, how are you? #bomdia In case the SELECT would be somet...
asked by 28.05.2015 / 01:52
2
answers

How to check if a constant exists in the class or in a namespace?

In PHP, to check if a constant exists we use the defined function. As below, for the two cases of constant declaration: const MY_TEST_1 = 'my test 1'; define('MY_TEST_2', 'my test 2'); var_dump(defined('MY_TEST_1'), defined('MY_TEST_2...
asked by 19.06.2015 / 14:06
2
answers

Picking date and time from a string

I want to "filter" string to get only the date that is in it, string is in that format:    SSC Napoli v Dnipro - Thursday 05/07/2015 04:05 PM What I want to get is just 07/05/2015 16:05 , I used explode : $data...
asked by 09.05.2015 / 01:23
2
answers

Regex in dynamic string of X characters, in dynamic content

Next, I have a page that generates content scrambled with dynamic and non-dynamic strings, I need to get a dynamic value between the | tabs, it contains random data / strings that change when loading the page. The variable I want to get h...
asked by 13.06.2015 / 07:44
2
answers

Block access to javascript files

I have a javascript file that does ajax requests for my API, but I do not want anyone to find out the link to it, is there any way to block access to this file? If you do not have some way to release so only the site can access?     
asked by 08.06.2015 / 03:21