ошибка on line 3

P
На сайте с 11.02.2018
Offline
8
416

<?php

$wordcounts = array( );
$words = split( " ", "CNN number Americans disapproving President Bush job
perance risen highest level presidency according CNN USA Today Gallup poll
released Monday According poll percent respondents disapproved Bush performance
compared percent approved margerror plus minus percentage points percent
figure highest disapproval rating recorded CNN USA Today Gallup poll Bush
president January approval percentage percent matches low point late March
point gap between those disapproved approved largest recorded during Bush tenure
As Bush prepares address nation Tuesday defend Iraq policy just percent those
responding poll approved handling war percent disapproved Full story approval
rating Iraq unchanged poll late May disapproval figure marked increase
percentage points But poll found issues other Iraq war dragging down Bush numbers
Respondents expressed stronger disapproval handling economy energy policy health
care Social Security lone bright spot president poll handling terrorism which
scored percent approval rating compared just percent disapproved presidents
worst numbers latest poll came issue Social Security respondents disapproving
performance margmore percent percent Bush made changing Social Security system
signature issue second term He proposed creating voluntary government sponsored
personal retirement accounts workers younger Under proposal workers could invest
portion their Social Security taxes range government selected funds exchange
guaranteed benefits retirement plan run instiff opposition Democrats accounts are
too risky undermine Social Security system Some Republicans are wary taking such
politically risky economy only percent poll respondents approved Bush
performance compared percent disapproved On energy policy percent approved
percent disapproved health care percent approved percent disapproved poll results
based interviews Friday Sunday American adults" );
foreach( $words as $word )
{
$word = strtolower( $word );
if ( strlen( $word ) > 0 )
{
if ( ! array_key_exists( $word, $wordcounts ) )
$wordcounts[ $word ] = 0;
$wordcounts[ $word ] += 1;
}
}

$min = 1000000;
$max = -1000000;
foreach( array_keys( $wordcounts ) as $word )
{
if ( $wordcounts[ $word ] > $max )
$max = $wordcounts[ $word ];
if ( $wordcounts[ $word ] < $min )
$min = $wordcounts[ $word ];
}
$ratio = 18.0 / ( $max - $min );
?>
<html>
<head>
<style type="text/css">
body { font-family: arial, verdana, sans-serif; }
.link { line-height: 20pt; }
</style>
</head>
<body>
<div style="width:600px;">
<?php
$wc = array_keys( $wordcounts );
sort( $wc );
foreach( $wc as $word )
{
$fs = (int)( 9 + ( $wordcounts[ $word ] * $ratio ) );
?>
<a class="link" href="http://en.wikipedia.org/wiki/<?php echo($word);
?>" style="font-size:<?php echo( $fs ); ?>pt;">
<?php echo( $word ); ?></a> &nbsp;
<?php } ?>
</div>
</body>
</html>

Fatal error: Uncaught Error: Call to undefined function split() in E:\OpenServer\domains\php\Code\Глава 3. DHTML\Трюк 24. Создание диаграмм ссылок\linkgraph.php:3 Stack trace: #0 {main} thrown in E:\OpenServer\domains\php\Code\Глава 3. DHTML\Трюк 24. Создание диаграмм ссылок\linkgraph.php on line 3

dma84
На сайте с 21.04.2009
Offline
168
#1

http://php.net/manual/ru/function.split.php

(PHP 4, PHP 5)

split — Разбиение строки на массив по регулярному выражению

Внимание

Эта функция объявлена УСТАРЕВШЕЙ в PHP 5.3.0, и УДАЛЕНА PHP 7.0.0.

Есть следующие альтернативы:

preg_split()

explode()

str_split()

P
На сайте с 11.02.2018
Offline
8
#2

в книге написано что все должно работать

ME
На сайте с 03.07.2017
Offline
66
#3
Phpi:
в книге написано что все должно работать

А в вашей книге какую версию php сказано использовать?

P
На сайте с 11.02.2018
Offline
8
#4

не знаю там вроде не написано

ME
На сайте с 03.07.2017
Offline
66
#5

В книге же не написано что это будет работать на любой версии php... Вот вам выше и указали на причину, что на версии 7.0.0 и выше - не работает.

Используйте любую альтернативу:

preg_split()

explode()

str_split()

Или смените версию php на 5.6, к примеру

Но луше смените книгу. Эта вас точно ничему не научит

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий