Mr.Visitor
Mr.Visitor

Reputation: 1

Can you change file name using php?

So here's the idea. Can you change/rename the name of the file using php.I was thinkig like this

you have couple of pages all same "template" just different content and name for example you have some file named "portfolio-item-1.php" and if someone click "next" link it goes to "portfolio-item-2.php" so the same file just renamed and different content using ID's ?

It's maybe confusing but .. .

I know you can do this Database but, is there a way without database?

Upvotes: 0

Views: 262

Answers (2)

hookedonit
hookedonit

Reputation: 56

psynnott has the best method you would want to implement. you can use a namespace instead of an integer but the same applies.

Upvotes: 0

psx
psx

Reputation: 4048

You really don't want to do that! From what you say you're trying to do, a GET / POST would be far better.

E.g. link to portfolio-item.php?page=2 You can get the page number by:

$page = isset($_GET['page']) ? $_GET['page'] : 1;

This will set page to the ID in the URL if it's there, otherwise it'll use 1 as the page number.

Upvotes: 2

Related Questions