hello all..
I am using luminous php syntax highlighter in my codeigniter project. It is working i.e. it highlights the codes. But an error also encountered --
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 2
Filename: ci-syntax-highlight/highlight.php
Line Number: 30
Array ( )
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 2
Filename: ci-syntax-highlight/highlight.php
Line Number: 30
can anyone help me out???
7 10068
you are trying to access array, but the index you are using is not valid.
say, you have defined - $array[0]='asdf';
-
$array[1]='**';
Now you are trying to access: -
echo $array[2]; //but index 2 does not exists
-
thanx johny...
but i m not getting this point in my code....
here's the highlight.php - - <?php
-
-
/* place in application/config/hooks.php:
-
$hook['display_override'] = array(
-
'class' => 'highlight',
-
'function' => 'hook',
-
'filename' => 'highlight.php',
-
'filepath' => 'hooks/ci-syntax-highlight',
-
'params' => array()
-
);
-
*/
-
class highlight {
-
-
public function highlight() {
-
if (!class_exists('luminous')) {
-
require_once dirname(__FILE__) . '/luminous/luminous.php';
-
}
-
}
-
private function hook_cb($matches) {
-
$meta = $matches[2];
-
$code = $matches[3];
-
-
// parse the classes, don't worry about this if it's a [code]
-
if (strlen($matches[0]) && $matches[0][0] === '<') {
-
// code in <...> tags are legit. html so we need to unescape whatever they
-
// had to escape
-
$code = htmlspecialchars_decode($code);
-
preg_match('/class=([\'"])(.*?)(\\1)/', $meta, $m);
-
print_r($m);
-
$classes = preg_split('/\s+/', $m[2]);
-
if (!in_array('highlight', $classes)) return $matches[0];
-
}
-
$language = 'plain';
-
if (preg_match('/lang(uage)?=(.*)/', $meta, $m)) {
-
$language = $m[2];
-
if (strlen($language) && ($language[0] === '"' || $language[0] === "'")) {
-
if (($pos = strpos($language, $language[0], 1)) !== false) {
-
$language = substr($language, 1, $pos-1);
-
}
-
}
-
}
-
return luminous::highlight($language, $code);
-
}
-
-
public function hook($params = array()) {
-
$CI = & get_instance();
-
$output = $CI->output->get_output();
-
if (!isset($params['header']) || $params['header'] === true) {
-
if (isset($params['theme']))
-
luminous::set('theme', $params['theme']);
-
if (!function_exists('base_url')) {
-
$CI->load->helper('url');
-
}
-
luminous::set('relative-root',
-
base_url() . 'application/hooks/ci-syntax-highlight/luminous/');
-
$head = luminous::head_html();
-
// insert the stylesheets
-
$output = preg_replace('%</head%i',
-
"$head\n" . '$0', $output, 1);
-
}
-
$exps = array(
-
// ..
-
"/
-
\[(code)(.*?)\][ \t]*(?:[\r\n]|\r\n)?
-
(.*?)
-
\s*
-
\[\/code\]
-
/xs",
-
// <pre> or <code>
-
"/
-
<(pre|code)(.*?)>[ \t]*(?:[\r\n]|\r\n)?
-
(.*?)
-
\s*
-
<\/\\1>
-
/xs");
-
foreach($exps as $e) {
-
$output = preg_replace_callback($e, array($this, 'hook_cb'), $output);
-
}
-
echo $output;
-
}
-
}
nd i m getting error in this line -
$classes = preg_split('/\s+/', $m[2]);
plz help me out...
seems like there is no second match. what does the print_r() give you?
thanx Dormilich..
print_r output - - Array (
-
[0] => class='highlight'
-
[1] => '
-
[2] => highlight
-
[3] => '
-
)
-
// some more repetitions of that
are you sure it’s line #28? the error doesn’t make sense in this context.
yes , error comes in line -
$classes = preg_split('/\s+/', $m[2]);
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RU |
last post by:
Hi,
I am working on a porting project to port C/C++ application from
unixware C++, AT&T Standard components to g++ with STL on Linux. This
application has been working properly on...
|
by: Stu |
last post by:
I am trying to build the xerces shared library with 2.3.0 version of
their source code on an AIX 5.1 32 bit machine with the following
version of the g++ compiler
/usr/local/bin/g++ -v
Reading...
|
by: Mike |
last post by:
I am having a problem when a field is spaces being undefined. I wasn't
sure if the problem was Excel or Javascript, so I thought I would post
here first.
The users are able to select from a drop...
|
by: Codemutant |
last post by:
**** Post for FREE via your newsreader at post.usenet.com ****
I just cannot find what is undefined in this code.
|
by: Foolster41 |
last post by:
I'm rather new to C++ programing. I'm using the dev-C++ program on a
windows XP OS. I'm trying to compile the code for a multi user dungeon
(MUD) called circle-mud.
When I compile I get the...
|
by: Don Vaillancourt |
last post by:
What's going on with Javascript.
At the beginning there was the "undefined" value which represented an
object which really didn't exist then came the null keyword. But
yesterday I stumbled...
|
by: Chris Beall |
last post by:
If you want your code to be bulletproof, do you have to explicitly check
for the existence of any possibly-undefined variable?
Example: window.outerHeight is defined by some browsers, but not...
|
by: matty |
last post by:
Hi,
I recently got very confused (well that's my life) about the
"undefined" value. I looked in the FAQ and didn't see anything about
it. On...
|
by: Michael Sgier |
last post by:
Hi
i get thousands of messages like below. How shall i resolve that?
Thanks
Mcihael
Release/src/Utility/RawImage.o: In function `CMaskImage::CMaskImage(int,
int, char const*)':...
|
by: VK |
last post by:
(see the post by ASM in the original thread; can be seen at
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b>
as an option)
As that is not in relevance to...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |