Skip to content

Tag: php

Twig: Selecting certain blocks and rendering them

I am intergrating the twig templating engine into a PHP application. In particular, I would like to use the twig engine to render forms. Having had a look at how symfony2 uses twig to render form widgets, they have a huge template file which contains all the widgets like so: The question I have is how can I &…

Ajax and Jquery in Symfony

I’m a beginner in Symfony (version 2), I have a project achieved with plain basic PHP, and now I’m redoing my pages in dealing with Symfony framework, and arrived to my jquery ajax functions, surely, …

Passing an operator as a parameter to odbc_execute()

I am taking my first tentative steps into prepared statements (and falling flat on my face). Previously, I built the following from $_GET and echoed it back – the code was working fine and it returned what I expected from my simple test database. and when I try to code it using a prepared statement, eve…

Json encode an entire mysql result set

I want to get json with php encode function like the following i want the output json to be something like that but the output json is look like the following As you realize that there is comma at the end, i want to remove it so it can be right json syntax, if i removed the echo “,”; when

get return from echo

I’m working with some functions that echo output. But I need their return so I can use them in PHP. This works (seemingly without a hitch) but I wonder, is there a better way? Example: Answer no, the only way i can think of to “catch” echo-statements it to use output-buffering like you alrea…

PHP date of birth checker

I am currently using the following PHP code to check date of birth, the code uses the american mm/dd/yyyy although I’m trying to change it to the british dd/mm/yyyy. I was hoping someone could tell me what to change: Answer the explode is breaking up the string into an array, it is using the / as the se…

How to output in CLI during execution of PHP Unit tests?

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things. I have tried the following (similar to the PHPUnit Manual example); With the following result: Notice there is none of the expected output. I’m using the HEAD versions of the git repos as of September 1…

PHP – jQuery – Comet chat

I am looking for a solution for PHP and comet. I would like to make a chat using Ajax to send the message. I call the function using jQuery and send data, it is simple. But the problem is in retrieving new messages. How to retrieve messages using the new solution comet? I need a simple example. I am looking