0

私はWeb開発(特にCIフレームワークのphp)が初めてです。この質問はあなたにとって非常に簡単な質問のはずですが、私は 1 時間グーグルで検索しましたが、まだ解決策が見つかりません。

画像 ( imgフォルダー内の logo.png) を表示し、ルートディレクトリに配置した css ファイル ( styleフォルダー内のstyle.css) をリンクします。

ここに画像の説明を入力

しかし、画像を表示してcssをリンクしようとすると、空白の空のWebページしか得られません。これは私のhtmlコードです:

<!DOCTYPE html>
<html>
    <head>
        <title>My First Design</title>
        <link href="<?php echo base_url();?>style/style.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <h1><img src="../../img/logo.jpg" />My First Web Design</h1>
        <p>
        I have been working on honing, and in some cases, learning new graphical skills in the past few weeks. So, I have been                          extensively watching Adobe Illustrated tutorials and working on my existing Photoshop knowledge and basically trying to                     get a hang of the software beyond basic image editing and digital painting.
        </p>
        <p>
        From a beginner’s point of view, the world of graphical design is quite vast… at times intimidating and there is no limit                           to creative options. One could branch out into any form of graphical design… illustrations or web-design or logo &                                  advertising and so much more. At the same time, one does not need to limit the options to just these.
        </p>
    </body>
</html>

これは私のconfig.phpbase_url です:$config['base_url'] = 'http://localhost/ciGlassProject/';

私は次のようないくつかの異なる方法を試しました:

  1. base_url の代わりに site_url を使用する
  2. URLを手動で入力してください
  3. $config['base_url']さまざまな方法で値を変更します。しかし、それらのどれも機能していません。
4

1 に答える 1

1

動作するはずのベースURLを使用できます。

<img src="http://localhost/ciGlassProject/img/logo.jpg" />

それを行うためのより良い方法は、phpを使用してベースURLを取得することです。つまり、サイトを移動した場合、新しい場所で実行するためにURLを何度も変更する必要はありません。そのためには、単純なphp呼び出しを使用できます。

<img src="<?php echo base_url(); ?>img/logo.jpg" />
于 2013-02-28T14:33:27.163 に答える