- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Other’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Theoretical Example:
about.php:
<?php
$title = "his is About page"
include "links.php"
?>
<html>
<head>
<?php meta_links(); ?>
links.php:
function meta_links()
{
echo "<title><?php $title; ?></title>"
But when I try this, I get an error for the $title
variable in links.php
not being defined (which makes sense, I guess).
How is this done?
You need to pass a parameter. Google “PHP function parameter” for more info, but in brief;
about.php
<?php
$title = "This is About page";
include("links.php");
?>
<html>
<head>
<?php echo meta_links($title); ?>
links.php
<?php
function meta_links($my_title) {
return $my_title;
}
?>
@beverleyh thank you. Makes sense. I’ll try that when I get home.
https://github.com/DaniSpringer/Projects/commit/1b96617fb970f23026d876f46c2b9dcb24ad023b
Glad it helped.
The green “Good answer!” is a form of answer acceptance here :)