我刚开始学习Laravel,可以完成控制器和路由的基础知识.
我的操作系统是Mac OS X Lion,它位于MAMP服务器上.
来自routes.php的代码:
Route::get('/', function() {
return View::make('home.index');
});
Route::get('businesses', function() {
return View::make('businesses.index');
});
Route::get('testing', function() {
return View::make('testing.index');
});
Route::get('hello', function() {
return "<h3>Hello world!</H3>";
});
Run Code Online (Sandbox Code Playgroud)
这有效,视图显示完美,''然而''我想要尝试和做的是在视图中包含CSS,我尝试添加到目录中的样式表的链接,但页面显示为默认浏览器字体甚至虽然CSS在HTML中!
这是来自views文件夹中的企业的index.php:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<p>Business is a varied term. My content here.
Run Code Online (Sandbox Code Playgroud)
我尝试在我的其他视图文件夹(测试)中使用Blade模板引擎来显示CSS但是尽管它在测试文件夹中,CSS仍未显示!
我怎样才能克服这个问题,并且变得更好 - 因为我正在慢慢地学习这个框架.
我在Windows 7上运行Apache 2.26,PHP 5.39 mod_ssl/2.2.6 OpenSSL/0.9.8g.
PHP工作正常,Apache也是如此.
但是,我想尝试为每个目录创建自定义php.ini文件,用于我的测试站点.
我可以 - 并且确实 - 使用php_flag但是想尝试创建一个有效的自定义php.ini文件.我尝试谷歌这个,但找不到任何相关的东西.
这是我目前用于C:/ www/vhosts/localhost/testsite1的.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
#RewriteCond %{REQUEST_fileNAME} !\.php -f
#RewriteRule .* index.php
AddType text/html .asp
AddHandler application/x-httpd-php .page
php_value include_path "./php:/php/"
Run Code Online (Sandbox Code Playgroud)
然而,我在php中自定义php.ini进行了更改,以便关闭短标签[仅用于测试],但它没有提取它,而是代码显示的PHP代码.
任何帮助都表示赞赏; 它会非常有用!
(请记住,这个Apache安装是开发/测试的)
我在MAMP上的localhost上创建了这个简单的Twig页面:
<html>
<head>
<style type="text/css">
table {
border-collapse: collapse;
}
tr.heading {
font-weight: bolder;
}
td {
border: 0.5px solid black;
padding: 0 0.5em;
}
</style>
</head>
<body>
<h2>Automobiles</h2>
<table>
<tr class="heading">
<td>Vehicle</td>
<td>Model</td>
<td>Price</td>
</tr>
{% for d in data %}
<tr>
<td>{{ d.manufacturer|escape }}</td>
<td>{{ d.model|escape }}</td>
<td>{{ d.modelinfo|raw }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是它背后的代码:
<?php
// include and register Twig auto-loader
include 'Twig/Autoloader.php';
Twig_Autoloader::register();
// attempt a connection
try {
$dbh = new PDO('mysql:dbname=world;host=localhost', …Run Code Online (Sandbox Code Playgroud) 我一直在学习使用PDO和PHP的基础知识,我的查询工作正常.这是代码:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
$hostname = "localhost";
$username = "test";
$password = "test";
try {
$db = new PDO("mysql:host=$hostname;dbname=goodsdb", $username, $password);
//echo "Connected to database"; // check for connection
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$sql = "Select * from items";
$result = $db->query($sql);
foreach ($result as $row) {
//echo $row["goods"]. "<br />";
}
$db = null; // close the database connection
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
<p>
<?php
echo $row["goods"];
?>
</p>
<p>
<?php
echo $row["auctiondate"];
?> …Run Code Online (Sandbox Code Playgroud) 这是我的HTML页面:
https://jsfiddle.net/62czmtvt/2/(实际看到HTML页面正常工作)
来自JSFiddle的代码:
:root {
background-color: #FFFACD;
}
div.infoguide {
width: 240px;
font-family: Arial, sans-serif;
font-size: 13px;
background-color: #F0FFF0;
}
div {
margin: 5;
padding: 0;
border: 0;
outline: 0;
}
A:link {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:visited {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:active {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:hover {
text-decoration: underline;
color: rgb(204, 51, 51);
}
body {
margin-left: 0px;
margin-top: 0px;
}
body,
td,
th {
font-family: …Run Code Online (Sandbox Code Playgroud)