GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php quik question (https://gfy.com/showthread.php?t=236934)

alex79 02-15-2004 07:09 AM

php quik question
 
what is the function with wich i can see if a string is in other string?

nibbi 02-15-2004 07:21 AM

You can use substr_count() to count the number of times a given string is found within another.

http://us4.php.net/manual/en/function.substr-count.php

jennycards 02-15-2004 07:21 AM

ereg(), eregi()

Ash@phpFX 02-15-2004 07:27 AM

or preg_match()

natkejs 02-15-2004 07:44 AM

strstr($string, "string")

find the first occurance of "string" in $string ... this command is pretty useful.

in your case...

if (strstr($string, "UHH")) { echo "YES.. UHH is in string!" }

alex79 02-15-2004 08:06 AM

thanks for your reply

i want to make an redirect to another page if a string is in the referer page...i've tryed eregi() and strstr() and both times i get same error

this is the code i used:
PHP Code:

<?
if (strstr($_SERVER['HTTP_REFERER'], "amateur"))
{ header("location: [url]http://www.mydomain.com/amateur.html[/url]"); die();}
?>

and this is the error i get when i come to this page from another page which the "amateur" in the url:


"Cannot add header information - headers already sent by (output started at /home/..............) "

any ideea why i get this error?

natkejs 02-15-2004 09:55 AM

ehm you shouldn't include any html tags there, make it like this.
edit: nevermind this, it's VBulletin adding the html tags even when outputing PHP code.

PHP Code:

<?
if (strstr($_SERVER['HTTP_REFERER'], "amateur")) { header("Location: http://www.mydomain.com/amateur.html"); };
?>

also any output command such as echo/print being executed before your re-direct will cause it to fail. so make sure there is nothing in your script that outputs info before it's supposed to re-direct.

sweet7 02-15-2004 10:05 AM

Quote:

Originally posted by asher
or preg_match()
:thumbsup

Chris 02-15-2004 10:07 AM

feel free to use my code
php.hahahahahahahaha%%#)I$)#.PHP!

that should take care of ya

cheers :glugglug


All times are GMT -7. The time now is 12:15 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123