0

Hey,
Here is the situation: I have a gallery of images that are being displayed with javascript that requires the image files to be saved as img1, img2, img3, etc. I am currently trying to write the php code that keeps track of the number of image files and allows more images to be added into the gallery by a user. The only problem that I can't get past is saving the images in a proper format using the string "image" and then the variable number of images in the folder. Any combination of "." and the string and variable just print as the string only. Help please?

Current code:

$path = "img" . "$filenum";
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

Well, I am thoroughly shamed. The code I have posted is correct, save that the variable I was using is $fileNum, not $filenum. Apologies for the confusion

0

$fileNum does not need to be dquoted,
in double quotes the php parser will search text, for variables
all of these work

$path = "img$fileNum";
$path = "img".$fileNum;
$path = 'img'.$fileNum;

putting the variable inside quotes is slower (infinitessimally) than leaving it outside where it belongs, above line3 (single quoted text) is fastest, the php parser does not waste time looking for variables where none exist.
May not matter for 1 image, may matter for many images

Edited by almostbob: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.