Is there a easy way or what is the best way for generating the DOM with PHP? I have read a little of PHP DOMDocument but I don't really understand it.
I would like to generate a simple HTML5 DOM start.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<title>★ Site Title ★</title>
<link rel="stylesheet" href="css/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="js/functions.js"></script>
</head>
<body>
</body>
</html>
Related
It's a weather reporting web-page. Just to see what I can do. There are three iframes,
The first includes a listing of some of the parameters in an JSON file from an API. I works just the way I expected.
The second is a chart of data - a different API call from the first one. No problems there.
The third will be forecast data, but the PHP code in the file is ignored! Every time!
This is the code (I've shortened it by eliminating the formatting and printing):
<html>
<head>
<link rel="stylesheet" type="text/css" href="./style/weather.css" />
<title>The Weather Report</title>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="./css/Florida.css" />
</head>
<body>
<?php
print "ready";
$forecast = get_web_page("http://api.weatherstack.com/current?access_key=1a134310341ff3b6fadb73bd1967baca&query=34232");
print $forecast;
$arrWeather = json_decode($forecast, true);
?>
</body>
</html>
All the HTML shows in wheen I view the age source"
<html>
<head>
<link rel="stylesheet" type="text/css" href="./style/weather.css" />
<title>The Weather Report</title>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="./css/Florida.css" />
</head>
<body>
ready
That's it! The API request works perfectly when I plug it directly into the browser.
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>**********</title>
<link href="css/main.css" rel="stylesheet" />
<link href="css/home.css" rel="stylesheet" />
</head>
<body>
<?php
// top navigation
require_once("require/top_navigation.php");
// header
require_once("require/header.php");
// main
require_once("require/main.php");
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="js/main.js"></script>
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v5.0&appId=411386782258918&autoLogAppEvents=1"></script>
</body>
</html>
...
I haven't done much direct php for a while, but when I seem to use the require_once it adds a blank text element followed by 1. I've looked all over google and everyone that I've come across says it's because of BOM. So I checked on the editor that I use 'Visual Studio Code', and it's not enabled, by default it's UTF-8 without BOM.
The apache software is Xampp.
I'm creating a website for homework and it's going to have multiple pages. I'm using bootstrap 4 and for each page, I have to declare a lot of links and scripts on the head of the HTML.
My question is if it's possible to add a single link via HTML or a PHP include so I can use a single line for all the additions and edit them all on a single file.
This is what I have
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
I want something like this
<head>
<title> </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="alltheotherlinksandscripts.php">
</head>
Or this
<html>
<head>
<title></title>
<?php
include_once "alllinks.php";
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body> </body>
</html>
You can. Put the header in a separate php file and you can include it in all files.
<head>
<?php include('header.php'); ?>
</head>
Yes, you can set all links (js/css libraries) in one file i.e alllinks.php
and call that file in your <head> part like..
<head>
<?php include('alllinks.php'); ?>
</head>
I am trying to merge two html heads by php include()-ing a php file (which contain the header for reusability) into another. The code works but it results into this:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/custom-theme/jquery-ui-1.10.3.custom.min.css">
<link href='http://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="./js/jquery191.js" ></script>
<script type="text/javascript" src="./js/jqueryui1103.js" ></script>
</head><html>
<head>
<title>Add Employee Form</title>
<link rel="stylesheet" type="text/css" href="./css/addform.css">
<script type="text/javascript" src="./js/talentform.js" ></script>
<script type="text/javascript" src="./js/form_submission.js" ></script>
</head>
Which is I think against the standards. Is there a way of merging those two heads into one without violating the standards? By the way, I am using CodeIgniter 2 Framework, if it helps. Thanks!
I'm programming a website in PHP 5 and for convenience I've elected to use includes for the header and footer on each page.
My html and head setup looks like this atm, and had been unchanged since I started
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html lang='en'>
<head>
<meta charset='utf-8'>
<!--[if IE]><![endif]-->
<title>TITLE</title>
<meta name='description' content=''>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold&subset=latin' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='css/default.css'>
<link rel='stylesheet' href='css/bbeditor.css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script src="js/jQuery.js" type="text/javascript"></script>
<script src="js/bbeditor.js" type="text/javascript"></script>
</head>
As you can see I use some jquery, a nice simple bbeditor for user input and the google font api. What started happening was that I could only load the last mentioned javascript file for some reason, in this case, it would be the bbeditor. not only that, the font api just wont load at all.
I should mention that the CSS files load perfectly fine however.
Does anyone know what's going on?
Try using firebug's "Net" tab, it will show you all the requests and responses. Firstly check the Status column and, if something's wrong, the response.
Try closing your one-line tags:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html lang='en'>
<head>
<meta charset='utf-8' />
<!--[if IE]><![endif]-->
<title>TITLE</title>
<meta name='description' content='' />
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold&subset=latin' rel='stylesheet' type='text/css' />
<link rel='stylesheet' href='css/default.css' />
<link rel='stylesheet' href='css/bbeditor.css' />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script src="js/jQuery.js" type="text/javascript"></script>
<script src="js/bbeditor.js" type="text/javascript"></script>
</head>
Note the /> at the end of link and meta tags.