This Forum has been archived there is no more new posts or threads ... use this link to report any abusive content
==> Report abusive content in this page <==
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Integrating FBML and PHP in my facebook app?
02-19-2014, 12:41 PM
Post: #1
Integrating FBML and PHP in my facebook app?
I'm trying to use blocks of fbml and blocks of php in my facebook application. However, I am trying to use my php variables in the fbml and it's not working.

For example I want to use the fb:time and use a variable created in my php block above it called $start. But it won't let me because its not an "integer".

for example I have something like

<?php
$start = 1235298413; //this number will change from queries to DB
?>

<fb:time t=$start tz="America/New_York" />

Can someone help please? I want to display this time.

Ads

Find all posts by this user
Quote this message in a reply
02-19-2014, 12:42 PM
Post: #2
 
There are a few problems. First, you need quotes around your number. That's less important, because since $start is outside of PHP scope, it's being parsed just like regular HTML, which doesn't recognize $start, of course. There are a number of ways to do this.

1) Add PHP scope around your variable:

<fb:time t="<?= $start ?>" tz="America/New_York" />

2) Extend your overall scope to include the HTML code, but output it through PHP:

<?php
$start = 23434;

echo "<fb:time t=\"$start\" tz=\"America/New_York\" />";

OR

echo '<fb:time t="'.$start.'" tz="America/New_York" />';
?>

This is pretty simple PHP knowledge, so I'm under assumption you don't know PHP very well. I'd suggest that trying to make a Facebook app is not the best way to learn.

Ads

Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)