0

I have a function call rsstotime

function rsstotime($rss_time) { // convert to unix timestamp}

if I call it like this:

$time = rsstotime('Wed, 05 Aug 2015 11:21:00 BST');
//returns 1438773660 the correct timestamp

If I call it like this

$pub = 'Wed, 05 Aug 2015 11:21:00 BST';
$time = rsstotime('$pub');
//returns 946598400

I'm guessing the string $pub is being converted instead. I thought I could pass a variable into a function like that?

bertster
  • 383
  • 1
  • 3
  • 17

2 Answers2

1

When you use single quotes the variables are not used. If you use double quotes they are.

But why use string literals when you can just use the variable like func($var)?

Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74
0

You don´t need to use quotes '' in variable name, just use like this:

$time = rsstotime($pub);
bicho
  • 134
  • 1
  • 11