Autocomplete styles through the include php function in PhpStorm - php

I'm using PhpStorm and I love it, especially the auto-complete feature. I tried to use the autocomplete while including the CSS files with the "include" function, like this:
<!doctype html>
<html lang="en">
<head>
<?php include("head.php"); ?>
</head>
<body>
<div id="page">
<div id="menu" class="heigth-100 bg-blue">
<?php include("menu.php"); ?>
</div>
<div id="content" class="heigth-100 bg-gray padding">
<h2 class="I-want-to-autocomplete">Home</h2>
</div>
</div>
</body>
</html>
Where the function include(head.php); are my css files. But once this is done, the auto-complete stops working because they are not directly linked to the document.
Is there any way that auto-complete founds the styles in the include function?

Related

Remove script tag from url YII 1.17

I have a yii 1.17 application. Problem is any one can inject scripts in url. Ex: If user puts this after page url ?redir=%3C/SCript%3E%3CsvG/onLoad=prompt(7)%3E application gives popup with given message.
How can i avoid this?
Main Layout:
<html lang="en">
<head>
</head>
<body>
<?php ?>
<app-header></app-header>
<md-content id="wrapper" layout-fill layout-margin layout-padding>
<section class="grid_outer">
<?php echo CHtml::encode($content); ?>
<div class="md-grid-container md-grid-padding">
</div>
</section>
<app-footer></app-footer>
</md-content>
</body>
</html>
View File:
<app-login></app-login>

For which <html> tag was the tag </html> in the footer.php closed?

I am reading << practical php and mysql building eight dynamic web applications>>.In the appendix A--web site design ,there are two files--header.php and footer.php.
It is the header.php file.
<?php
require("config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<title><?php echo $config_sitename; ?></title>
<link href="stylesheet.css" rel="stylesheet">
</head>
<body>
<div id="header">
<h1><?php echo $config_sitename; ?></h1>
</div>
<div id="menu">
Home
•
About
•
FAQ
•
Technical Details
</div>
<div id="container">
<div id="bar">
<?php
require("bar.php");
?>
</div>
<div id="main">
It is the footer.php file.
</div>
</div>
</body>
</html>
I have two questions .
1. why the tag in header.php don't close itself,such as
<div id="main"> don't close
<div id="container"> don't close
<body> tag don't close
All of them closed in the footer.php ,if the header.php is long and complicated,it is hard to write the footer.php file to close all the tags in the header.php.
2.There is a tag </html> in the footer.php,but there is no <html> tag in the header.php,what is the matter?
I haven't read that book but typically if a page is broken up into 3 parts :
header.php
content.php
footer.php
Then you can imagine the following block of HTML code :
<!DOCTYPE html>
<html>
<body>
<div class="main">
<!--other content-->
</div>
</body>
</html>
Being the same as this :
<!--header.php-->
<!DOCTYPE html>
<html>
<body>
<div class="main">
<!--header.php end-->
<!--content.php-->
<!--other content-->
<!--content.php end-->
<!--footer.php-->
</div>
</body>
</html>
<!--footer.php end-->
So for your first question, these tags can't be closed within header.php itself because that would not allow content from content.php to be inserted within the .main container.
For your second question, the <html> tag was probably left out accidentally.
A good practise is to include a comment beside the closing tag to make things clearer. For example, your footer.php could look like this :
</div><!--#main-->
</div><!--#container-->
</body>
</html>
Doing so would prevent a lot of careless mistakes in case a tag was closed earlier than intended; or if the closing tag was missed out, you could spot it easily.

yield equivelant from Rails

I want to have a standard layout for all my pages on my php site. Is there anything in php similar to Rails's yield
Example:
<!DOCTYPE html>
<html>
<head>
<!--STYLESHEETS AND SUCH HERE-->
</head>
<body>
<!--NAVBAR HERE-->
<?php
//YIELD THINGY HERE
?>
<!--FOOTER HERE-->
</body>
</html>

problem in shorthand php tag of files in cake php

I have this simple code:
<html>
<head>
<title>My Cake Blog Application</title>
<?=$html->css('styles');?>
</head>
<body>
<div id="container">
<div id="content">
<?=$content_for_layout;?>
</div>
</div>
</body>
</html>
I saved it in app/views/layouts
name it to default.ctp
the output in browser only shows me css('styles');
also I have styles.css in app/webroot/css
it is not working in my browser then I tried this string for begin and close:<?php echo();?>
again not worked
<html>
<head>
<title>My Cake Blog Application</title>
<?php=$html->css('styles'); echo();?>
</head>
<body>
<div id="container">
<div id="content">
<?php=$content_for_layout; echo();?>
</div>
</div>
</body>
</html>
Either use full tags as you already found out or enable short tags in php.ini: How to enable PHP short tags?
<html>
<head>
<title>My Cake Blog Application</title>
<?php echo $html->css('styles'); ?>
</head>
<body>
<div id="container">
<div id="content">
<?php echo $content_for_layout; ?>
</div>
</div>
</body>
</html>

Using header("Location") from a template include file / Process include and save in variable

I am trying to figure out a way to do this:
I want to have a core template file (structure.php):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include_once(NAKIDROOT."includes/head.php"); ?>
</head>
<body>
<div id="all">
<div id="page">
<?php include_once("includes/header.php"); ?>
<div id="main">
<div id="left">
<?php include_once("includes/left.php"); ?>
</div>
<div id="content">
<?php include_once("includes/messages.php"); ?>
<?php include_once("includes/page.php"); ?>
</div>
<?php include_once("includes/footer.php"); ?>
</div>
</div>
</div>
</body>
</html>
I would like the includes to have the ability to run header(Location) if needed so it seems like I would need to somehow have php read each of those include files.
Is there a way to render the include to check for headers and things first, and put its contents in a variable, so my structure file would instead be like this?:
<div id="page">
<?php echo($header); ?>
<div id="main">
<div id="left">
<?php echo($left); ?>
</div>
<div id="content">
<?php echo($messages); ?>
<?php echo($page); ?>
</div>
<?php echo($footer); ?>
</div>
</div>
You cannot send headers after you've started on the HTTP response body (i.e. after you've output something, this includes things outside of <?php tags). A quick fix is to use output buffering using ob_start() and related functions. This is just a band-aid though; you should try to restructure your code so you don't have to rely on output buffering if possible.
To use ob_start(), simply call it at the top and call ob_end_flush() on the bottom of your script.

Categories