0

How can I get:

$img = new imageProcessing("333.jpg",200); 

In a dynamic from considering cam_id=333

This is not working:

$img = new imageProcessing(" . $cam_id. '.jpg'",200); 
Rizier123
  • 58,877
  • 16
  • 101
  • 156
Mark Henry
  • 2,649
  • 7
  • 40
  • 48
  • `$img = new imageProcessing($cam_id.'.jpg',200); ` – Daan May 04 '15 at 15:00
  • 1
    Your concatenating is just messed up! Simply: `$img = new imageProcessing($cam_id . ".jpg", 200);` – Rizier123 May 04 '15 at 15:01
  • it needs the "" around the image name – Mark Henry May 04 '15 at 15:04
  • @mark So you want the argument to be: `"333.jpg"` ? – Rizier123 May 04 '15 at 15:06
  • 1
    In which case: $img = new imageProcessing('"' . $cam_id . '.jpg"', 200); – Chris Evans May 04 '15 at 15:06
  • @mark No, it does not. Quotation marks are used to define literal strings. Variables, such as `$cam_id` can be used without them even if they represent string values. – skreborn May 04 '15 at 15:06
  • I think he wants it to output "333.jpg", with the quotes, for whatever reason. @ Mark You can use single quotes ( ' ) and then put double quotes inside them, like $var = 'this is a "quote" '; – Chris Evans May 04 '15 at 15:08
  • The other option, sorry, is: $img = new imageProcessing("\"$cam_id\".jpg", 200); - Using double quotes within double quotes can be done by 'escaping' them, by putting a backslash ( \ ) before them, like $var = "This is a \"quote\" "; And you can also use variables within double quotes without concatenating, like: $var = "Chris"; echo "My name is $var"; - will output My name is Chris. – Chris Evans May 04 '15 at 15:09

0 Answers0