I would like to know when and why should I use {$var} and when (and why) should I use the simple form $var Answer You would use the latter when a) not accessing an object or array for the value, and b) no characters follow the variable name that could possibly be interpreted as part of it.
Tag: php
echo MySql column names and values
What I need is to have a list name => value to be able to make MySql queries. My problem is, I can access MySql records, but I also need to access table’s column names, what should I change in my code? Thanks ok, so now why can’t I join the values to then make my sql queries? I just
Parallel processing in PHP – How do you do it?
I am currently trying to implement a job queue in php. The queue will then be processed as a batch job and should be able to process some jobs in parallel. I already did some research and found several ways to implement it, but I am not really aware of their advantages and disadvantages. E.g. doing the parall…
What does the ‘period’ character (.) mean if used in the middle of a PHP string?
Here is some example code: What does the period character do in the middle of each piece of the string? For example, Answer This operator is used to combine strings. EDIT Well, to be more specific if a value is not a string, it has to be converted to one. See Converting to a string for a bit more detail.
Generating a random password in php
I am trying to generate a random password in php. However I am getting all ‘a’s and the return type is of type array and I would like it to be a string. Any ideas on how to correct the code? Thanks….
Switch statement in PHP injected HTML
It’s 1! I want to do something like that, in other words use the switch statement in PHP templates. This …
Does php5.3 support mysqli extension without any additional manual configurations/updates?
I’ve built a PHP based website with MySQL as the back-end, and am planning to put it online now. The issue is that I’ve used mysqli extension in the PHP scripts extensively, and right now I’m worried …
php pchart pie chart problem with 0 value
I have a problem with my pie chart when I have 0 values $MyData->addPoints(array(10,20,20,15,23),”Data”); This works fine and converts to percentages across a pie chart however if any of these values are 0 which could happen as I’m dealing with counts and these are really variables in my …
Pretty-Printing JSON with PHP
I’m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode. Here is an example script: The above code yields the following output: This is great if you have a small amount of data, but I’d pref…
How do I ignore a moved-header with file_get_contents in PHP?
I have programmed a simple content-user, that uses file_get_contents, but unfortunately for my IP the site now gives a 302 error that forwards to an image. For all other users the normal site is …