this post was submitted on 21 Nov 2024
72 points (97.4% liked)

PHP

547 readers
1 users here now

Welcome to /c/php! This is a community for PHP developers and enthusiasts to share and discuss anything related to PHP. From the latest updates and tutorials, to your burning questions and amazing personal projects, we welcome all contributions.

Let's foster an environment of respect, learning, and mutual growth. Whether you're an experienced PHP developer, a beginner, or just interested in learning more about PHP, we're glad to have you here!

Let's code, learn, and grow together!

founded 1 year ago
MODERATORS
 

Ever wanted to provide your arguments to a function as a comment?

https://gist.github.com/RikudouSage/18defbf1746322a289ae78b2980d0115

#php #cursed #wtf #programming @php

top 11 comments
sorted by: hot top controversial new old
[–] [email protected] 29 points 1 week ago

the function reads the comment added after the function is called using a backtrace and uses them as arguments

How marvelously creative. What an abomination.

[–] [email protected] 21 points 1 week ago

No, my eyes! Forever unclean!

[–] [email protected] 17 points 1 week ago

Do you really want an answer for that?

[–] [email protected] 16 points 1 week ago

What a terrible day to have eyes

[–] [email protected] 12 points 1 week ago

no. never wanted that.

[–] [email protected] 6 points 1 week ago* (last edited 1 week ago)

This reminds me of a trick to get multiline strings in javascript before they where formally introduced. If you coerce a function in to a string you get the source code for that function, comments and all. This meant that you could write a function with multiline comments and then pick out the middle part. Haven't tested it so it's probably sligthly wrong but it was something like:

var multiLine = ('' + function () {/*
line 1
line 2
*/});
multiLine = multiLine.substring(16, multiLine.length-4);
[–] [email protected] 4 points 1 week ago (1 children)

huh, that does look kinda clean though

[–] [email protected] 5 points 1 week ago

@python I mean, it's already an abomination, I can at least write a clean code.

[–] [email protected] 3 points 1 week ago
[–] [email protected] 2 points 1 week ago
[–] [email protected] 2 points 1 week ago